Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Access customized global variable through COC

(0) ShareShare
ReportReport
Posted on by 459

Hi Folks,

I want to declare a customized Global variable in form extension class and want to use in Other datasource field extension class of that form.

I declare Variable as per below code in Form extension class  

[ExtensionOf(formstr(XXX))]
final class XXXFrm_Extension
{
    
    public       NumberSeq              numberSeq;

    void init()
    {
        if (! numberSeq)
        {
            XXX
        }
       
        next init();
    }

And want to use NumberSeq  variable in other extension class like Data field. But I'm getting error as "NumberSeq is not declared"

[ExtensionOf(formDataFieldStr(XXX,ProjTable,ProjId))]
final class XXXFrm_ProjIdFieldCtrl_Extension
{
    public void modified()
    {
        next modified(); 

       

        if(projTable.projid)
        {
            projTable.XXX = rProjIdnew;
         }
         
    }
}    
         

Please help me out this.

  • Verified answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Access customized global variable through COC

    Hi D365FO Avatar,

    Try to use element keyword to get the global variables in the form like below.

    element.numberSeq;

    If it doesn't work create one parm method in the form extension and simply return the buffer.

    [ExtensionOf(formstr(XXX))]
    final class XXXFrm_Extension
    {
        
        public       NumberSeq              numberSeq;
    
        void init()
        {
            if (! numberSeq)
            {
                XXX
            }
           
            next init();
        }
        
        public NumberSeq getNumSeq()
        {
            //return the buffer
            return numberSeq;
        }
    }

    Now you can call the above method in any of your extension class using element keyword or form run object.

    [ExtensionOf(formDataFieldStr(XXX,ProjTable,ProjId))]
    final class XXXFrm_ProjIdFieldCtrl_Extension
    {
        public void modified()
        {
            next modified(); 
            NumbeSeq numSeq = element.getNumSeq();
            if(projTable.projid)
            {
                projTable.XXX = rProjIdnew;
             }
             
        }
    }    

    Thanks,

    Girish S.

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…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans