web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Get/Set SharedVariable

(0) ShareShare
ReportReport
Posted on by 850

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

I have the same question (0)
  • Suggested answer
    Flydancer Profile Picture
    1,332 on at

    Do you mean something like that? sliong.wordpress.com/.../crm-2011-execution-context-javascript-shared-variable

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    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.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    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 .

  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at

    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!

  • naZir Profile Picture
    850 on at

    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.

  • gdas Profile Picture
    50,091 Moderator on at

    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.

  • Mahendar Pal Profile Picture
    45,095 on at

    Can you share where you read about using it in javascript?

  • Suggested answer
    sandeepstw Profile Picture
    4,601 on at

    Hi,

    Please follow this article -

    sliong.wordpress.com/.../crm-2011-execution-context-javascript-shared-variable

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

    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.

    docs.microsoft.com/.../clientapi-execution-context

    docs.microsoft.com/.../setsharedvariable

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans