Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

javascript increment variable on parent record

Posted on by 600

Hi

I have a variable on lead:   var activityNumber = "1";

I want to increment this number each time a new activity is created. To do this I have want to call this variable on the activity and increment, but I am not able to recall the variable. I have tried alert (window.top.opener.activityNumber); and just window.top.activityNumber but get error message that the variable is not defined. 

How can I get the variable and increment it from activity to lead. 

Many thanks for help! 

*This post is locked for comments

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: javascript increment variable on parent record

    Hi Martin,
    Why you are not creating real time workflow . I think this will be easiest way to do this using workflow  .

    Please have a look below reference where I have answered--

    https://community.dynamics.com/crm/f/117/t/308613

    In addition you can try with this -

    var no = window.parent.opener.Xrm.Page.getAttribute("new_activityno").getValue();
    var incrmentNo = no + 1;
    window.parent.opener.Xrm.Page.getAttribute("new_activityno").setValue(incrmentNo);


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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans