Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Javascript By lookups field

(0) ShareShare
ReportReport
Posted on by 15

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
    gdas 50,089 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
    hedi bouneni 15 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
    gdas 50,089 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 Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,307 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans