This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Populating properties from completion dialog

ejmoska - Tuesday, May 17, 2016 6:38 AM:

Hello, i have a question/suggestion

Is it possible to populate properties of itemtype from completion dialog? Lets say a user receives a task to analyze something, and the property analysis_results would show up in his completion dialog, so he would not have to open up the form for the item type.

On the workflow process map it is possible to assign a variable which show's up on the completion dialog, it would be amazing if the type of variable could be a property.

Hope you can understand the idea

Thanks



stevestojanovski - Tuesday, June 7, 2016 10:00 PM:

Does this help: https://www.razorleaf.com/2014/10/aras-innovator-activity-variables-in-workflow/

Method code is required to get the value the user entered in the completion dialog for the variable and then update the controlling item's property.  The article doesn't have the method code posted, but if you want a copy reply back here and I can see if I can make that available to you.

 



ejmoska - Wednesday, June 8, 2016 4:16 AM:

Hello , Steve,

If you could provide the code it would be great help for me.

Thanks!



stevestojanovski - Wednesday, June 8, 2016 8:05 AM:

Sure. Here you go.  Note that this method calls an external method "Get Controlled Item" that must be in your database.  See the inline comment below.

//System.Diagnostics.Debugger.Break();

//Get Innovator item from the context item
Innovator inn = this.getInnovator();

//get the activity assignment from the database
Item currentActivityAssignment = this.newItem("Activity Assignment","get");
currentActivityAssignment.setID(this.getProperty("AssignmentId"));
Item currentAssignmentResult = currentActivityAssignment.apply();

//Get the activity variable by its named from the activity assignment
Item actVarValues = currentAssignmentResult.fetchRelationships("Activity Variable Value");
//Get the first activity variable value.  In this case, there is only one so get its value property.
string variableValue = actVarValues.getRelationships().getItemByIndex(0).getProperty("value","");

//Get the Controlled Item which is the Simple ECO item so we can update it
//Get Controlled Item method code is available from Aras Community Solution Workflow Automation examples:
//www.aras.com/.../project-view.aspx
Item controlledItem = this.newItem(this.getAttribute("type"),"Get Controlled Item");
controlledItem.setID(this.getID());
controlledItem = controlledItem.apply();
if (controlledItem.getItemCount() != 1)
{
  return inn.newError("Error retrieving the controlled item:" + controlledItem.getErrorDetail());
}
//Get the current hours spent property on the ECO so it can be added to
string currentHours = controlledItem.getProperty("rl_draft_changes_hours_spent");
string newValue = string.Empty;
if (string.IsNullOrEmpty(currentHours))
{
 //Current value empty.  set the new value to activity value
 newValue = variableValue;
}
else
{
 //Add the new value to current value to create the new value
 //Convert strings to numerics to perform addition
 double newValueNumeric = Convert.ToDouble(currentHours) + Convert.ToDouble(variableValue);
 //convert the numeric back to a string for Aras
 newValue = newValueNumeric.ToString();
  
}

//Update ECO drafting hours spent property with a new value
Item updateECO = this.newItem(controlledItem.getType(), "edit");
updateECO.setID(controlledItem.getID());
updateECO.setProperty("rl_draft_changes_hours_spent", newValue);
Item updateECOResult = updateECO.apply();
if (updateECOResult.isError())
{
 return inn.newError("An error occurred attempted update the ECO's Drafting Hours Spent property.");
}

return this;