Skip to main content

Notifications

Announcements

No record found.

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

  • Suggested answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: Get/Set SharedVariable

    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.

  • Suggested answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: Get/Set SharedVariable

    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
    sandeepstw Profile Picture
    sandeepstw 4,601 on at
    RE: Get/Set SharedVariable

    Hi,

    Please follow this article -

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

  • Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Get/Set SharedVariable

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

  • gdas Profile Picture
    gdas 50,085 on at
    RE: Get/Set SharedVariable

    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.

  • naZir Profile Picture
    naZir 850 on at
    RE: Get/Set SharedVariable

    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.

  • Suggested answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Get/Set SharedVariable

    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!

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Get/Set SharedVariable

    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
    gdas Profile Picture
    gdas 50,085 on at
    RE: Get/Set SharedVariable

    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
    Flydancer Profile Picture
    Flydancer 1,332 on at
    RE: Get/Set SharedVariable

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

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,735 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,466 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans