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 increment variable on parent record

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Christoph Pock Profile Picture

Christoph Pock 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans