Having trouble with BPM condition, and custom code


(Kevin Kearney) #1

My overall goal with this BPM is to detect whether someone has changed the POHeader.PromiseDate field, and if they have prompt the user to change the PORel.PromiseDate in the release lines to reflect the change. I have set it up as a method directive preprocessing, since I only want it to run when changed by an updatable query.


My first issue is the condition circled in red. I have it set up such that it should return true when the PromiseDate field has been changed.
For some reason it is not returning true. I do not understand why. Maybe I am misunderstanding the purpose of the condition?

My second issue is with the code I am using to update he PORel fields.

> foreach(var POHed in ttPOHeader.Where(pt => pt.Updated() || pt.Added()))
> {
> 	var PORel = (from pl in Db.PORel where pl.Company == POHed.Company && pl.PONum == POHed.PONum select pl);
> 	foreach(var rel in PORel)
> 		{
> 		rel.PromiseDt = POHed.PromiseDate;
> 		Db.Validate();
> 		}
> }

When the code does run, none of the fields are changed. Again, despite my best attempts I cannot figure out why it does not work as intended.

I might going about this entirely the wrong way, so any feedback would be appreciated.

(Pierre Hogue) #2

Hello Kevin,

It is an annoying behavior, but I do have the same issues. Even after just adding messages before the condition were not showing !
It is as the DLL of your BPM has not been replaced. The way I overcome this is I do a recycle IIS via the admin console. Make sure there is no active tasks running prior to do this…
Once done the BPM behaves correctly.


(Kevin Kearney) #3

I solved the custom code bit by removing the Update() line as well as the .Where(…).

@Hogardy Thanks for the advice. I will see if that fixes my condition problem. I suspect, though, that I am using the condition in an unintended way.

(Kevin Kearney) #4

I replaced the condition with a custom code validation check. It now works the way I want. If anyone finds this post helpful, let me know! :slight_smile:

foreach(var POHedr in ttPOHeader)
	var POHed = (from pl in Db.POHeader where pl.Company == POHedr.Company && pl.PONum == POHedr.PONum && pl.PromiseDate != POHedr.PromiseDate select pl);
	foreach(var hed in POHed)
				return true;
return false;

(Kevin Kearney) #5

(if anyone has a better way of checking if the length of the POHed dataset is larger than 0 let me know)

(Chris Conn) #6

POHed.Count() > 0