Hi All,
Environment :365Fo
Requirement : We created customization Vendor workflow its working fine after workflow competed its show view history everything working good
Client request If any vendor need any update after completed workflow again client click EDIT button on vendor form and continues the workflow .
Below is my code if edit and save the vendor its ask dialog YES/NO dialog, if click YES again workflow start its working fine.
Issues : Once if click No on dialog ,I want revert what customer enter in vendor form ,Even after click NO on dialog its save the data.
[FormDataSourceEventHandler(formDataSourceStr(VendTable, VendTable), FormDataSourceEventType::Written)]
public static void VendTable_OnWritten(FormDataSource sender, FormDataSourceEventArgs e)
{
VendTable VendTableorg;
FormRun form = sender.formRun();
FormDataSource VendTable_ds = form.dataSource(formDataSourceStr(VendTable,VendTable)) as FormDataSource;
VendTable VendTable = VendTable_ds.cursor();
str acnum;
Dialogbutton db;
boolean stament = false;
VendTable this_Orig = VendTable.orig ();
acnum = VendTable.AccountNum;
db = box::yesNo("Modifying vendor"+""+acnum+""+"will reset the workflow approval status, continue? ", dialogButton::Yes, "YesNo Box Example");
ttsbegin;
if (db == dialogButton::Yes)
{
select forupdate vendTable where vendTable.AccountNum == acnum;//vendTable.AccountNum;
ttsbegin;
if(VendTable.ApprovalStatus == HcmApprovalStatus::Approved)
{
VendTable.WorkflowState = VendTableChangeProposalWorkflowState::NotSubmitted;
VendTable.doUpdate();
}
ttscommit;
form.doResearch();
}
else
{
error("changes reverted");
}
}


