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

Notifications

Announcements

No record found.

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

Responsible AI policies

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

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans