Javascript onChange CRM 2011
-
Wednesday, June 20, 2012 9:56 AM
HI All,
I am a bit stuck with the javascript. I have a option set field which changes its value with help of workflow. OnChange of this field doesn't work.
function onchange()
{if(Xrm.Page.getAttribute("new_quotepresent").getValue() == 100,000,001)
{
Xrm.Page.getAttribute(“new_quotepresent”).fireOnChange();alert("Quote is Created");
//crmForm.all.mxc_productrevenue.disabled = true;
}
}Any help will be appreciated.
All Replies
-
Wednesday, June 20, 2012 10:07 AMchange your code like below
function onchange()
{if(Xrm.Page.getAttribute("new_quotepresent").getValue() == 100000001)
{
Xrm.Page.getAttribute("new_quotepresent").fireOnChange();alert("Quote is Created");
}
}
I hope this helps. If my response answered your question, please mark the response as an answer and also vote as helpful.
Mubasher Sharif
Check out my about.me profile!
http://mubashersharif.blogspot.com
Linked-In Profile
Follow me on Twitter!
- Edited by MubasherSharif Wednesday, June 20, 2012 1:03 PM replace ” with "
-
Wednesday, June 20, 2012 10:22 AM
HI Mubashir,
still no luck, the filed against which the onchange event is firing is in opportunity, On creation of a quote a workflow runs and updates this field as yes. this field is a disabled fiels with no manual interaction. My ultimate aim is to diable a few fields if a quote is created.
Any more suggestions.
-
Wednesday, June 20, 2012 10:47 AMModerator
Hello,
Try to use following code:
function onchange() { if(Xrm.Page.getAttribute("new_quotepresent").getValue() == 100000001) { Xrm.Page.getAttribute("new_quotepresent").fireOnChange(); alert("Quote is Created"); } }Anyway I'm not sure regarding scenario you are trying to implement. Could you share this scenario?Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)
-
Wednesday, June 20, 2012 11:04 AM
Hi Andrii,
This is the same as Mubashir propsed but doesnt work. Scenario is simple as i said some fields in opportunity are to be disabled if quote is created. I have added a option set with default value NO. Once the quote is created a workflow runs and updates the opportunity option set to YES. (Works fine).
Now after the option set value changes to YES, i would like to disable a few fields on opportunity.
-
Wednesday, June 20, 2012 11:46 AMModerator
Hi Andrii,
This is the same as Mubashir propsed but doesnt work. Scenario is simple as i said some fields in opportunity are to be disabled if quote is created. I have added a option set with default value NO. Once the quote is created a workflow runs and updates the opportunity option set to YES. (Works fine).
Now after the option set value changes to YES, i would like to disable a few fields on opportunity.
In case you will attentively look at code you will notice difference:
Mubashir - Xrm.Page.getAttribute(“new_quotepresent”).fireOnChange();
Mine - Xrm.Page.getAttribute("new_quotepresent").fireOnChange();
I believe it is possible to see difference - quotes so suggestions are different.
To disable some fields you should use setDisabled code. Unfortunately I was not able to see where you've used it.
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)
- Proposed As Answer by MubasherSharif Wednesday, June 20, 2012 12:09 PM
-
Wednesday, June 20, 2012 12:09 PM
Yes, I had changed the quotes and tried it but still not able to get the result. Yes, you are right that you can't see any setDisabled code as i was testing if other things are right.
-
Wednesday, June 20, 2012 1:42 PMModerator
It seems that I've understood your issue. Your scenario is:
1. You create some record and you have form of record opened.
2. You have workflow which triggers on create of record and changes the value of picklist.
3. Once value is changed you want your script to be triggered.
Am I right?
In case yes - your script would not be triggered because change is performed on the server side and you are waiting the change event to appear on the client side. To make it work you will have to write script which will periodically recheck value of field using OData - http://technet.microsoft.com/en-us/library/gg334427 or http://technet.microsoft.com/en-us/library/gg309549
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)
- Proposed As Answer by Andrii ButenkoMVP, Moderator Wednesday, June 20, 2012 3:51 PM
-
Wednesday, June 20, 2012 3:42 PM
Hi Andrii,
You are absolutely right. I think its time for me to do some hardwork.