web
You’re offline. This is a read only version of the page.
close
Skip to main content
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

I have the same question (0)
  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Javascript By lookups field

    Hi ,

    Please check below reference -

    passion4dynamics.com/.../

  • 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

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

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

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
UllrSki Profile Picture

UllrSki 2

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans