Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Javascript By lookups field

(0) ShareShare
ReportReport
Posted on by 19

Hallo,

I need your help,i try to create a javascript code for this scenario:

i want to add a lead then a company for this lead i want that when i go to new "company" that the field name (Lead ) be automatically set as company name.


Thanks.

0652.Unbenannt2.PNG8272.Unbenannt3.PNG

*This post is locked for comments

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Javascript By lookups field

    Make sure you are passing executionContext in the form editor where  you registered "SetLocalStorage" function.

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

  • hedi bouneni Profile Picture
    19 on at
    RE: Javascript By lookups field

    hallo Goutam ,

    it is my code :

    function SetLocalStorage(executionContext)

    {

    var formContext = executionContext.getFormContext();

    var firstName = formContext.getControl("fullname").getAttribute().getValue().toString();

    localStorage.setItem("FirstName",firstName );

    }

    i wanna to storage the fullname from Lead (onsave)

    but he schow me thismistake :

    TypeError: Cannot read property 'getFormContext' of undefined

       at SetLocalStorage (4cosmobn.crm4.dynamics.com/.../new_LeadAufgabe

       at eval (eval at RunHandlerInternal (4cosmobn.crm4.dynamics.com/.../ClientApiWrapper.aspx, <anonymous>:1:1)

       at RunHandlerInternal (4cosmobn.crm4.dynamics.com/.../ClientApiWrapper.aspx

       at RunHandlers (4cosmobn.crm4.dynamics.com/.../ClientApiWrapper.aspx

       at ExecuteHandler (4cosmobn.crm4.dynamics.com/.../ClientApiWrapper.aspx

       at Mscrm.TurboForm.Control.CustomScriptsManager.$Dq_1 (4cosmobn.crm4.dynamics.com/.../formcontrols.js

       at Mscrm.TurboForm.Control.CustomScriptsManager.executeHandler (4cosmobn.crm4.dynamics.com/.../formcontrols.js

       at Mscrm.TurboForm.Control.CustomScriptsManager.executeHandlerByDescriptor (4cosmobn.crm4.dynamics.com/.../formcontrols.js

       at 4cosmobn.crm4.dynamics.com/.../formcontrols.js

       at 4cosmobn.crm4.dynamics.com/.../global.ashx

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Javascript By lookups field

    Hi ,

    Please check below reference -

    passion4dynamics.com/.../

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans