web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Answered

X++ Code - Open CustOpenTrans form

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

*This post is locked for comments

I have the same question (0)
  • Verified answer
    István Orosz Profile Picture
    2,137 on at

    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

  • István Orosz Profile Picture
    2,137 on at

    Hi mrpequit,

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

    Thanks,

  • Suggested answer
    PA-22040759-0 Profile Picture
    6,194 on at

    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();
    }


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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans