I need a BPM to fire when a job is being created from an order. I’ver look through multiple job / order related method directives but cant seem to find the right one. What would the directive be?
thanks
I need a BPM to fire when a job is being created from an order. I’ver look through multiple job / order related method directives but cant seem to find the right one. What would the directive be?
thanks
Try Data Directive.
What do you need the BPM to do? As @24x7 says, a Data Directive on JobProd with a condition of added row and OrderNum field <>0 would fire but might not easily be able to do what you need.
A little more context would help.
Hey
I thought about that first but figured a MD might better as the code only needs to fire on create, not every time data changes. I have since set a Data Directive but i get an error when i try to update a field. The error i get is ‘The row has been modified by another user’… Here is my code and i have tried 2 options to set the field
Option 1
var jobHeadRow = (from r in Db.JobHead.With(LockHint.UpdLock)
where r.Company == currentCompany &&
r.JobNum == jobNum
select r).FirstOrDefault();
if (jobHeadRow != null)
{
jobHeadRow.UserChar1 = res;
Db.Validate();
}
Option 2
var jobHead = (from r in ttJobHead
where r.RowMod == "A"
select r).FirstOrDefault();
jobHead.UserChar1 = res;
The field i want to populate is JobHead.UserChar1 and the process that invoking the new row is from Sales Order, Order Line, Open with Job Manager, Create Job
Any ideas on the error would go a long way, its an error that i have come across a few times and i think ive got around them with guess work…
Thanks
If you want to use a Method directive, then do a trace on Job Manager to tell you what BO fires when you click the Create Job button. Have your BPM fire on that BO, and put in whatever conditions you need so that only the jobs you WANT to add that column to get modified.
The error you are getting is because you are reading and then modifying the record after it was already written. Then in your screen, you don’t have the latest copy, so you get the “modified by another user”. the system doesn’t know who modified it… just that it has been modified. How does it know this? Well, there is a field called RowRev, which is an integer number… it is increased each time a change is made. when you attempt to change the record again, we look and if the value is higher in the database than the value you originally read, we know that something else changed it.
Now, back to your original problem: There are TWO types of data directives… one is the “standard” and one is the in-trans… if you change to the in-trans, then you are modifying the value that is in memory BEFORE it gets written. so… if you read and modify that in-transaction temporary value before it gets written, you should not have this problem.
Thanks for the replies so far. When the BPM was in Standard, the code processed but i was unable to set the field value as mentioned. I moved the BPM to In Transaction and now i get a different bunch of errors…
The process i am using to create the job row is as follows:
in Order Entry, select the Order Line in Lines / List, Open With Job Manager. In Job Manager, i select the Order Line and click Create Job then select the ‘Order Release’ button to get the next number and click OK. upon clicking OK, i get the error ‘NullReferenceException’ which i know leads to a object with a non reference.
I commented out all of my code except this and it ran ok. I added a messagebox response to prompt after it ran and i got 2 messageboxes
var jobHead = (from r in ttJobHead
where r.RowMod == "A"
select r).FirstOrDefault();
Then i added this code underneath which produced the error:
var projID = jobHead.ProjectID;
var jobNum = jobHead.JobNum;
var partNum = jobHead.PartNum;
Im guessing the values im trying to obtain are not available yet or at all
I was able to solve my issue. Method Directive on JobManager.CreateJob. I collected the JobNum using
var getJobNum = newJobNum;
var jobHead = (from r in Db.JobHead
where r.Company == currentCompany
&& r.JobNum == myJobNum
select r).FirstOrDefault();
i got the ‘newJobNum’ from using a trace and found the JobManager transaction using this which matched the original error i was getting,
Thanks for all of the input