I’m still a noob when it comes to Kinetic Application Studio. My request here is to review my approach and ask “Did I do this in a reasonably correct way”?
Requirement TLDR:
On the Job Tracker/Job Entry screen, populate a value that is retrieved elsewhere.
Details:
In our implementation, A job’s first operation on the “main” manufacturing line is Assembly 0, Operation 40. User wants to see the StartDate/time for Assembly 0/Op 40 on the header level page of the Job.
In pseudo-sql, we need to retrieve this:
Select
StartDate
from erp.JobOper jo
where JobNum = ‘xxxxxx’ and AssemblySeq = ‘0’ and OprSeq=40;
Approach I took
I created a custom view KCC_Calculated.Op40StartDate. to hold the value.
I created function (DisplayFunctions.GetOp40StartDate) to accept JobNum as the input parameter and return Op40StartDate. If the job hasn’t started yet, or if we can’t find it, we return an empty string for the Op40StartDate.
I created a text box control, set it to read only. I set Behavior “On Create” to call the function passing JobHead.JobNum. It returns a string “Op40StartDate”.
In the row-update event, I bind the field to Op40StartDate, and assign it the Value “{actionResult.Op40StartDate}”.
This is the text of the function.
I am open to all comments (with the possible exception of the formatting of the date/time, as it was reusing the legacy code, and that’s “the way it’s always been”.)
//Wrap everything in the service context
this.CallService<Erp.Contracts.JobEntrySvcContract>
(svc =>
{
// set to true to see debug popup messages.
var debug = false;
// return default blank value
this.Op40StartDate = "";
//This will create a structured JobEntryTableset object.
var jets = svc.GetByID(this.JobNum);
//Loop through JobOper
foreach (var jo in jets.JobOper)
{
var oprSeq = jo.OprSeq;
if ((int)jo.OprSeq == 40)
{
if (debug) this.PublishInfoMessage("StartDate =" + jo.StartDate + ", StartHour=" + jo.StartHour, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
// calculate new Op40StartDate
if (jo.StartHour != null && jo.StartDate !=null)
{
decimal startHour = (decimal)jo.StartHour;
decimal formattedTime = Math.Round(((startHour - Math.Truncate(startHour)) * 60 * 0.01m) + Math.Truncate(startHour), 2);
var Text = Convert.ToDateTime(jo.StartDate).ToString("MM/dd/yy") + " " + formattedTime.ToString();
this.Op40StartDate = Text;
if (debug) this.PublishInfoMessage("Op40StartDt =" + Text, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
}
} // if
} // foreach JobOper record
} // svc
);


