Hi All,
I wanted to know the use of get/Set_sharedVariable in js in MS CRM
Can anyone please explain me with some scenario or provide some useful link.
Thank you
*This post is locked for comments
Hi All,
I wanted to know the use of get/Set_sharedVariable in js in MS CRM
Can anyone please explain me with some scenario or provide some useful link.
Thank you
*This post is locked for comments
Not a very good example but let me try:
lets say on a record there is a button " Activate" or "Deactivate" when someone clicks on it then you want to do some action but you want to make sure the action should happen on once that button is pressed not by any other mean.
you can set a variable with the requirred key once this pressed post which you can get the variable using the same key.
Hi,
You indeed can use getSharedVariable & setSharedVariable property in Client API Execution Context which Sets the value of a variable to be used by a handler after the current handler completes.
if your code executes in the same execution ( on the same form - same threaded event) you can indeed use it. But i just wonder - why you cant use a traditional global variable method.
Hi,
Please follow this article -
sliong.wordpress.com/.../crm-2011-execution-context-javascript-shared-variable
Can you share where you read about using it in javascript?
Hi Ahmed ,
Could you please share your requirement so that we can help you . In addition also share the details where you have been confused .
I believe all the shared variable details has been shared in above post . I dont think apart from that anything else in Dynamics CRM.
No. it is available for Java Script also. i Have checked it but did not understand. And the scenario for which it can be used i don't know. And in plug in it is there that i know. I am confused with Java Script.
Hi,
In additon to that we have concept of shared variable in CRM which you can use in plugins, to share data between plugins running on pre and post.
www.toplinestrategies.com/.../crm-2015-enhance-your-plugins-using-shared-variables
msdn.microsoft.com/.../gg328579.aspx
There is not get/set variable used in JS script, I hope you are not confuse with the getValue() and setValue() method in javascript which is used to get and set value of the form field.
docs.microsoft.com/.../getvalue
docs.microsoft.com/.../setvalue
Hope it will help!
In addition you can also create fields and make it hidden in the form and stored your variable there and used anywhere get the value anywhere in the form .
Hi Ahmed ,
First of all there is no such shared variable available in terms of dynamics CRM perspective. You an use global variable concept which are available in JavaScript language.
www.w3schools.com/.../js_scope.asp
There are many scenario can have , I remember in my project I used to keep some common configuration key/value(third party URL, Some Common Config Value) in dynamics CRM entity. I need those when my form load , what I did I retrieve those key/Value using JS Web API request and stored it in a global array object type variable in the first method of onload event of the form. I have several JS web resource reference in the form and used the global array variable in almost all the web resource. By doing this I reduce number of API rrequest in form onload.
Hope this helps.
Do you mean something like that? sliong.wordpress.com/.../crm-2011-execution-context-javascript-shared-variable
André Arnaud de Cal... 291,735 Super User 2024 Season 2
Martin Dráb 230,466 Most Valuable Professional
nmaenpaa 101,156