Programmatically select Save and suppress prompt on Order Update

Hi community. I am trying to figure out how to select the Save button programmatically from an oTrans() update call happening on a form event. I need the change to be saved for my function to have accurate data to return. My hope is that by selecting Save programmatically, the dialog box will not generate for the user.

Background: I have added a checkbox to a Sales Order form customization. I have a function being triggered by 2 different method directives to update pricing based on criteria and BO method used. I want to trigger one of the BPM’s (and as a result function) to run after the user selects the checkbox. I am using a Click event handler to call the SalesOrderAdapterUpdateMethod which is simply running an oTrans.Update() call in the form. A BPM’s is triggered on the Update method. This accomplishes what I want, however each time the checkbox is selected, the user is prompted to select Save via Dialog box, at which point my function runs and updates pricing accordingly. I’ve read through several threads on here that talk about suppressing the dialog box (which I’ve been able to do), however I want to acknowledge (press Save), and then suppress. Simply suppressing results in no Save, which doesn’t produce the pricing updates I need.

I think this will solve your problem:

Also:

The SalesOrderAdapter is already part of the Base Layer for SO Entry. You should just be able to call oTrans.Update() directly.

Thanks Kevin. I did see that thread and tried using both of the suggested event calls in my customization. It seems though, that these each suppress the prompt without actually saving. Do you know of other event calls I could use? I’m still relatively new to customizations so I may be missing something.

Thanks for the comment on the SalesOrderAdapter, I sort of suspected that and will make that change!

Interesting. I always thought that if you executed oTrans.Update(), it always saved. Are you sure it isn’t saving? If the issue is that you’re not seeing other fields update with the changes, it could just be that the interface isn’t refreshing. If you try oTrans.Update() followed by oTrans.Refresh(), does that work for what you’re trying to do?

With the event call suppressing the save dialog, it doesn’t appear to be saving, at least the value of my checkbox is not changing which is my point of reference. If my checkbox is false, and I click it to true, it’s returning back to false, even with the oTrans.Refresh() command after. So far, the only thing that seems to work properly is if I use only oTrans.Update() and manually press “Yes” in the Save Dialog. If I select “No” in the Save dialog, it seems to retain that preference and not continue to prompt me, but also not save the changes each time it runs the oTrans.Update() command (which is another reason I want to programmatically save to prevent user issues with this). Below is the section of code I am using which works provided I say “Yes” in the save dialog.

private void ThickTreatmentV1_c_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **

	isThicknessChecked.Checked = !isThicknessChecked.Checked;
	
	//this.oTrans.SetCurrentEvent(TransactionEvent.None);
    this.oTrans.Update();
	//this.oTrans.Refresh();

} 

image

Is the ThickTreatmwntV1_c_Click method on the same checkbox as isThicknessChecked control variable? Because if it is, it looks like your method is unchecking the box before the update.

Yes, I am having to swap the boolean value on click, otherwise it’s not retaining the value before running the update.

Interesting. From here it looks like when you check the box, your custom method is unchecking it before the update, which would then fail to trigger the BPM, but I might be wrong, as I’m not 100% how the EpiCheckBox.Checked property interacts with the Click() method. I’ll play with this a little bit and see if I can figure out what exactly is happening. Is that checkbox bound to a Database Field?

Meanwhile, can you test the result if you remove that line, but uncomment the SetCurrentEvent and the Refresh?

private void ThickTreatmentV1_c_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **

	//isThicknessChecked.Checked = !isThicknessChecked.Checked;
	
	this.oTrans.SetCurrentEvent(TransactionEvent.None);
    this.oTrans.Update();
	this.oTrans.Refresh();

} 

Sorry for the delayed response here. I ended up being able to accomplish what I wanted by pivoting from an Event Wizard to a Form Event Wizard. I setup an event for “AfterFieldChange” and set it to my customized UDfield on the detail table (which is bound to the customization checkbox). I then used this.oTrans.Update(); call (which is linked to the MasterUpdate BPM) to call my function. Worth noting, when using the this.oTrans.Refresh(); command after the update call, it reverts the form back to the pre-click status.