Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

X++ Code - Open CustOpenTrans form

Posted on by 165

hi,

I'm trying to create a job to open "CustOpenTrans" form but whenever I declare args.record() to a specific customer, it tends to select all customers and takes a long time to open the form. How can I pass args to the form to only the specific customer

Below is my code: 

static void OpenFormByCodeB()
{ Object formRun;
Args args = new Args();
;
args.name(formstr(CustOpenTrans));
args.record(CustTable::find(AccountNum));

formRun = ClassFactory.formRunClass(args);
formRun.init();
formRun.run();
formRun.wait();
}

thanks!

  • Suggested answer
    PA-22040759-0 Profile Picture
    PA-22040759-0 6,194 on at
    RE: X++ Code - Open CustOpenTrans form

    Here is a crude example manipulating the query of the form:

    static void OpenFormByCodeB()
    { 
        FormRun formRun;
        FormDataSource fds;
        QueryBuildDataSource qbds;
        Args args = new Args();
        CustAccount accountNum = 'US-002';
       
        args.name(formstr(CustOpenTrans));
        args.record(CustTable::find(accountNum));
    
        formRun = ClassFactory.formRunClass(args);
        formRun.init();
        
        fds = formRun.dataSource(1);
        
        qbds = fds.query().dataSourceTable(tableNum(CustTrans));
        if (qbds)
        {
            SysQuery::findOrCreateRange(qbds, fieldNum(CustTrans, accountNum)).value(queryValue(accountNum));    
        }
        
        formRun.run();
        formRun.wait();
    }


  • István Orosz Profile Picture
    István Orosz 2,137 on at
    RE: X++ Code - Open CustOpenTrans form

    Hi mrpequit,

    If it has solved your problem, please mark as verified, otherwise give more details please.

    Thanks,

  • Verified answer
    István Orosz Profile Picture
    István Orosz 2,137 on at
    RE: X++ Code - Open CustOpenTrans form

    Hi,

    For the first sight, the code looks valid for me, the only issue is that CustOpenTrans form needs CustTrans record not CustTable record.

    Kind regards,

    István

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,339 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,177 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans