Set the RowMod in BPM

bpm

(Marlon Morawetz) #1

Hey there!
I am curently working on probably one of the simplest BPM’s ever, buuuut i am stuck, since i am having some problems with setting the RowMod.

Long:
My goal is, that whenever a User from a specific UserGroup is creating a Quote out of a Case (line only), 4 fields will be set to my values.
The whole Process ist based on the Helpdesk BO, the only method containing the custom fields I want to set is the “Quote/GetByID”. Currently i am using a “Post-Processing” because Pre-Processing does not really work.

I am able to set the fields an recocnize it, when the right user is calling the method.
My only Problem is, that only the Field are getting set, but not the data. Normally you now simply would save it. But as the whole thing doesn’t recocnize any changes you can’t save.

Short:
How can I set the RowMod or anything else, so that the User is able to click the save butten.
Even better, how can I call the “Save-Method”?

Thanks!


(Joshua Giese) #2

If you wanted to save the data from get by id then you need to call the Update Method in the BPM then call Get By ID again (add flag logic in call context that prevents your BPM from firing again on Get By ID) and set the DS param of the BPM from your own GetByID you ran (after the update)

Shorthand would be

  • GetByID Fires Post Process
  • Check if CallContext.CheckBox01 is true, if not call your BPM runs the code you need
  • Now set CallContext.CheckBox01 = true (this will help us prevent the BPM firing again when we call it manually)
  • Call the Update method passing the dataset
  • Call the GetByID method and set the current dataset to the result.

Make sure at some Else false logic point you set the CallContext.CheckBox01 back to false. Note that this isn’t the most elegant solution because you will call save and GetByID for every GetByID so make sure you have very very very specific conditions on when your custom code must be fired and not do it every time.


(Marlon Morawetz) #3

I think i should use the “Invoke BO Method” which wants a QuoteTableset. Now i only need to fill my dataset. How?


(Jason Hawthorne) #4

Just as Joshua said.

  1. Invoke BO Method (GetByID) - this will fill the dataset with your record
  2. Modify your dataset
  3. Invoke BO Method (Update) - this will update the DB with the modified dataset.

Don’t forget to change the RowMod in the dataset before you update otherwise nothing will update.


(Marlon Morawetz) #5

I think that the getbyid and update stuff is not the right solution. Isn’t there anyway i use my C# code to write directly into the database? Something like
foreach(var tt in ttQuoteHed){
Db.QuoteHed.Where(M => M.Company == tt.Company && M.QuoteNum == tt.QuoteNum). Set(M => M.QuoteType_c = “MyString”) .FirstOrDefault();
}

I managed to set all the fields including the RowMod. I set it to “U”, but then i get an Error “This is a duplicate entry of an existing record”…


(Ken Nash) #6

Not sure why the BPMs wouldn’t just work.

Here is some sample code that updates records.
You will need to make sure you use the Db.Validate() to write back to the database.

foreach(var temp in ttResults.Where(tt=>tt.Updated()))
{
	//this is the code that is needed for when you set data back to the database in a different business object then what you are calling
using (var txscope1 = IceDataContext.CreateDefaultTransactionScope())
	{
		var apinvmsc = Db.APInvMsc.Where(p=> p.VendorNum == temp.APInvMsc_VendorNum
										&& p.InvoiceNum == temp.APInvMsc_InvoiceNum
										&& p.InvoiceLine == temp.APInvMsc_InvoiceLine
										&& p.MscNum == temp.APInvMsc_MscNum
										).FirstOrDefault();
		
		if(apinvmsc != null)
	
		{
			apinvmsc.EWO_c =  temp.APInvMsc_EWO_c;
		
		}
		Db.Validate();
		txscope1.Complete();
	}
}

Changing a field from another table
(Marlon Morawetz) #7

Works just like a charm! Thank you all :slight_smile: