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 :
Finance | Project Operations, Human Resources, ...
Answered

How can I update tables from a View datasource??

(0) ShareShare
ReportReport
Posted on by

I have to update the BOM Names of the selected records from a form, with the name inserted from a dialog, into 2 tables, namely the BOMTable and BOMVersion.

Basically:

I select some records from the Form,  I click the update button, a dialog opens, the dialog has one empty field....what I write in the empty field needs to update the BOMTable and BOMVersion tables

The Form has a View as datasource.

I can read the View's records, and I can update the Tables with a given values, but I don't know how to pass/convert the View record from the Main method to the tables in the run() method:

public static void main(Args _args)
{

FormRun formRun = _args.caller() as FormRun;

//Read records
XYZ_RouteOprUpdView routeOprUpdView = _args.record() as XYZ_RouteOprUpdView;

//New Class instance
XYZ_RouteOprUpdUpdateBOMName bomNameUpdate = new XYZ_RouteOprUpdUpdateBOMName();

//Initialization
bomNameUpdate.parmMultiSelectionHelper(MultiSelectionHelper::createFromCaller(_args.caller()));

bomNameUpdate.parmRouteOprUpdView(routeOprUpdView);
bomNameUpdate.parmFormRun(FormRun);

// Prompt the dialog, if user clicks in OK it returns true
if (bomNameUpdate.prompt())
{
bomNameUpdate.run();
}

}

public void run()
{
BOMTable bomTable = multiSelectionHelper.getFirst();
BOMVersion bomVersion = multiSelectionHelper.getFirst() ;

while (bomTable && bomVersion)
{
ttsbegin;
bomTable.selectForUpdate(true);
bomTable.Name = bomTableName;
bomVersion.Name = bomVersionName;

bomTable.update();
bomVersion.update();

bomTable = multiSelectionHelper.getNext();
bomVersion = multiSelectionHelper.getNext();

ttscommit;
}


formRun.dataSource(tableStr(XYZ_RouteOprUpdView)).research(true);

}

My problem is that in the run() method I input a View record to the BOMTable and BOMVersion, that can't be implicitly converted into the table format.

BOMTable bomTable = multiSelectionHelper.getFirst();
BOMVersion bomVersion = multiSelectionHelper.getFirst() ;

bomTable ---> BOMTable  type

multiSelectionHelper.getFirst()  ------->XYZ_RouteOprUpdView type

But if I write:

BOMTable bomTable = multiSelectionHelper.getFirst() as BOMTable ; 

it returns a null record.

How can I retrieve the 2 Table records from the View records?

I have the same question (0)
  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: How can I update tables from a View datasource??

    Does your view have fields that you can use to find the BOMTable and BOMVersion records?

    If yes, use those fields to find the corresponding BOMTable and BOMVersion records. Then update those records.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,317

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 918 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 656 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans