When user selects multiple records and click on button, status should be updated for selected records.
High level resolution steps
- Create new button in the required form and override clicked method.
- Set the button property, multi-select option as “Yes” and show row labels as “Yes”.
- Write the code in Button clicked method using the MultiSelectionHelper class.
Detailed resolution steps
Step 1
Create a button in the required form. Set the button property, multi-select option as “Yes” & Auto declaration as “Yes”. Make sure the grid properties of the form, multi select as “Yes” and Show Row Labels as “yes”.
Step 2
Override the clicked method from button and write the following code.
[Control(“Button”)]
class BulkIssue
{
public void clicked()
{
//For multi select option:
MultiSelectionHelper selectionHelper = MultiSelectionHelper::construct();//Create instance of class
Set selectedRecords = new Set(Types::Record);//Declare a set of type record
super();
ISLEAMWorkOrderItemConsumptionTable workOrderItemConsumptionTable, workOrderItemConsumptionTableUpd; //Your table buffer
selectionHelper.parmDataSource(ISLEAMWorkOrderItemConsumptionTable_DS); //Set the datasource
workOrderItemConsumptionTable = selectionHelper.getFirst(); //assign to table buffer the reference to selected record(s)
if (workOrderItemConsumptionTable.RecId)
{
while (workOrderItemConsumptionTable)
{
selectedRecords.add(workOrderItemConsumptionTable);
info(strFmt(“Selected record.. %1”,workOrderItemConsumptionTable.WOItemConsumptionStatus));//Display selected record
// For updating status for button click
ttsbegin;
while select forupdate workOrderItemConsumptionTableUpd
where workOrderItemConsumptionTableUpd.RecId == workOrderItemConsumptionTable.RecId
{
if(workOrderItemConsumptionTableUpd.WOItemConsumptionStatus == ISLEAMWOItemConsumptionStatus::Requested)
{
workOrderItemConsumptionTableUpd.WOItemConsumptionStatus = ISLEAMWOItemConsumptionStatus::Issued;
info(“Issued”);
}
workOrderItemConsumptionTableUpd.update();
}
ttscommit;
workOrderItemConsumptionTable = selectionHelper.getNext();
ISLEAMWorkOrderItemConsumptionTable_ds.research(true);
}
}
}
}
Output
Multi-select option available for a button.
Once multiple records selected and click “BulkIssue” button, the status changed into “Issued” for selected records.