Skip to main content
Post a question

Notifications

Community site session details

Community site session details

Session Id : B6o5DoSkAoSAxlPKJWJBuq
Microsoft Dynamics CRM (Archived)

javascript increment variable on parent record

Like (0) ShareShare
ReportReport
Posted on 6 Feb 2019 11:07:11 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
    50,089 Moderator on 06 Feb 2019 at 12:21:14
    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 -

    1. var no = window.parent.opener.Xrm.Page.getAttribute("new_activityno").getValue();
    2. var incrmentNo = no + 1;
    3. 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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,440 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,569 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Loading complete