Cancel
Showing results for 
Search instead for 
Did you mean: 

SOA API - How can I add a SignOff User to the Workflow?

Creator
Creator

I have lauched the workflow with the following code successfully.

But how can I add the SignOff User to the task via SOA API?

 

WorkflowService wfService = WorkflowService.getService(connection);

ContextData contextData = new ContextData();

contextData.attachmentCount = 1;
contextData.attachments = new String[] { uid };// List of UID of objects to submit to workflow
contextData.attachmentTypes = new int[] { 3 };
contextData.processTemplate = "Perform-Change";
			
InstanceInfo instanceResponse = wfService.createInstance(true, null, "ABC", null, "My COmment", contextData);
13 REPLIES 13

Re: SOA API - How can I add a SignOff User to the Workflow?

Siemens Phenom Siemens Phenom
Siemens Phenom

You should be able to use the addSignoffs call in WorkflowManagementService.

Give it a try and if you get stuck post back and we'll try and help.

 

As a hint using the communication monitor in the rich client is usually a good way to find out what is going on.

Enable it using Window -> Show View -> Other... from the menu bar and pick Debug -> Communication Monitor.

You can use the menu in the view to turn on the request and response, then perform your action.

When I do this on my system I get the following;

 

000201.jpg

 

My workflow had no signoff profile defined.  If you use a signoff profile then the call is a little different.

 

 

 

 

 

Re: SOA API - How can I add a SignOff User to the Workflow?

Creator
Creator

Thanks for pointing to the Communication Monitor. Is is really helpful.
So I need to starte the workflow first and than add a the signoff user in a second call? Is it possible to do this in one server call?

InstanceInfo resp = wfService.createInstance(true, null, "ABC", null, "My Comment", contextData);

The response contains the job ModelObject

Job job = (Job) resp.serviceData.getCreatedObject(0);


From there I need to find the "EPMSelectSignoffTask" to use this EPMTask Object to use this for the addSignoffs call. 

CreateSignoffs s = new CreateSignoffs();
s.task = (EPMTask) job.get_all_tasks()[9]; // task

CreateSignoffInfo s2 = new CreateSignoffInfo();
s2.signoffAction = "SOA_EPM_Review";
s2.origin = null; // Not sure what I have to set
s2.originType = "SOA_EPM_ORIGIN_UNDEFINED"; 
s2.signoffMember = null; // set user object
s.signoffInfo = new CreateSignoffInfo[] {s2};

wfService.addSignoffs(new CreateSignoffs[] {s});


Is my understanding correrct?

 

 

 

Re: SOA API - How can I add a SignOff User to the Workflow?

Siemens Phenom Siemens Phenom
Siemens Phenom

I think you should be able to do this in a single call.

If you look at the docs for contextData there are two properties that look interesting;

 

java.lang.String processAssignmentList - the name of a process assignment list.

java.lang.String[] processResources - A list of comma-separated user login IDs that will be used to satisfy signoff profiles for each individual task.

 

If your jobs all need the same assignments then processAssignmentList may be the way to go.  You can create a PAL in the rich client (Tools -> Process Assignment List -> Create/Edit...), then you should be able to specify it's name in your contextData.

 

processResources looks a bit more flexible, but the doc is a bit cryptic, and this would probably need a bit more research to get working.

 

Caveat: I've not personally tried either of the above.

 

Regarding the CreateSignoffs.

The value for origin depends on the value for originType, and this depends in turn on the design of the workflow.

  • If the workflow has no signoff profile defined then originType will be SOA_EPM_ORIGIN_UNDEFINED and origin will be null.
  • If the workflow has a signoff profile and you are filling it in then set originType to SOA_EPM_SIGNOFF_ORIGIN_PROFILE, and set origin to the signoff profile object.

I think you can also use assignment lists with SOA_EPM_SIGNOFF_PROFILE_ADDRESSLIST.

 

The signoffMember needs to be a GroupMember, a ResourcePool, or an EPMAssignmentList object.

 

Re: SOA API - How can I add a SignOff User to the Workflow?

Creator
Creator

For some reason the processAssignmentList is not working in our TC installation. 
I need to find out how the processResources is working. 

The javadoc of Workflow.ContextData.processResources says

A list of comma-separated user login IDs..

Is it the windows username because we use LDAP for login or is this the UID of the user model object?


 

Highlighted

Re: SOA API - How can I add a SignOff User to the Workflow?

Siemens Phenom Siemens Phenom
Siemens Phenom

From the (somewhat limited) doc I would say it is the login name, and not the UID.

I should have a little time at the end of the week to try and make a simple example if you don't get it working before then.

Re: SOA API - How can I add a SignOff User to the Workflow?

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi @MF3,  I found a few minutes to do a test, and managed to get assignment lists working, but I couldn't get processResources working.

 

For the assignment list I did the following;

  • Created a simple workflow process containing just a Review task with the select-signoff-team profile set to 1 user from the Author role;

000202.jpg

 

000203.jpg

 

  • In My Teamcenter I created an assignment list to fill the profile;

000204.jpg

 

  • In the code set the assignment list as shown below (irrelevant bits of code removed for clarity).
    public static void main(String[] args) {
        WorkflowStarter wfStarter = new WorkflowStarter(args);
        wfStarter.login();
        try {
            wfStarter.startWorkflow("AAAA Review", "Admin PAL", "73020138", "001");
        }
        finally {
            wfStarter.logout();
        }
    }


    private void startWorkflow(final String templateName, final String assignmentList, final String item_id, final String revision_id) {
        try {
            // Find the target
            ItemRevision target = findItemRevision(item_id, revision_id);
            if (target == null) {
                logger.error("Couldn't find the target - returning");
                return;
            }

            // Start the workflow
            Workflow.ContextData context = new Workflow.ContextData();
            context.attachmentCount = 1;
            context.attachments = new String[]{target.getUid()};
            context.attachmentTypes = new int[]{1};
            context.processTemplate = templateName;
            context.processAssignmentList = assignmentList;
            final Workflow.InstanceInfo instanceInfo = wfService.createInstance(true, "",
                    target.get_object_string(), "AutoCreated", "AutoCreated Process", context);
            if (instanceInfo.serviceData.sizeOfPartialErrors() > 0) {
                logErrors(instanceInfo.serviceData);
            }
            else {
                logger.info("Instance Key : " + instanceInfo.instanceKey);
            }
        }
        catch (NotLoadedException e) {
            logger.error(e);
        }
    }


    private ItemRevision findItemRevision(final String item_id, final String item_rev) {
        logger.info("Finding Item Rev ... (ID=" + item_id + "/" + item_rev + ")");

        ItemRevision itemRevision = null;
        try {
            com.teamcenter.services.strong.core._2008_06.DataManagement.GetItemAndRelatedObjectsInfo findItemRevInfo[] = new com.teamcenter.services.strong.core._2008_06.DataManagement.GetItemAndRelatedObjectsInfo[1];
            findItemRevInfo[0] = new com.teamcenter.services.strong.core._2008_06.DataManagement.GetItemAndRelatedObjectsInfo();
            findItemRevInfo[0].clientId = item_id;
            findItemRevInfo[0].itemInfo = new com.teamcenter.services.strong.core._2008_06.DataManagement.ItemInfo();
            findItemRevInfo[0].itemInfo.ids = new com.teamcenter.services.strong.core._2008_06.DataManagement.AttrInfo[1];
            findItemRevInfo[0].itemInfo.ids[0] = new com.teamcenter.services.strong.core._2008_06.DataManagement.AttrInfo();
            findItemRevInfo[0].itemInfo.ids[0].name = "item_id";
            findItemRevInfo[0].itemInfo.ids[0].value = item_id;
            findItemRevInfo[0].itemInfo.useIdFirst = true;

            findItemRevInfo[0].revInfo = new com.teamcenter.services.strong.core._2008_06.DataManagement.RevInfo();
            findItemRevInfo[0].revInfo.processing = "Ids";
            findItemRevInfo[0].revInfo.nRevs = 1;
            findItemRevInfo[0].revInfo.id = item_rev;

            findItemRevInfo[0].datasetInfo = new com.teamcenter.services.strong.core._2008_06.DataManagement.DatasetInfo();
            findItemRevInfo[0].datasetInfo.filter = new com.teamcenter.services.strong.core._2008_06.DataManagement.DatasetFilter();
            findItemRevInfo[0].datasetInfo.filter.processing = "None";
            findItemRevInfo[0].datasetInfo.namedRefs = new com.teamcenter.services.strong.core._2008_06.DataManagement.NamedReferenceList[0];

            com.teamcenter.services.strong.core._2008_06.DataManagement.GetItemAndRelatedObjectsResponse findItemRev = dmService.getItemAndRelatedObjects(findItemRevInfo);

            itemRevision = findItemRev.output[0].itemRevOutput[0].itemRevision;
            if (itemRevision != null) {
                logger.info("Got ItemRevision " + itemRevision.get_item_id() + "/" + itemRevision.get_item_revision_id());
            }
        }
        catch (NotLoadedException e) {
            logger.error(e);
        }

        return itemRevision;
    }

 

  • Running the code gives the following;
INFO  tc.services.WorkflowStarter - Logging in as author.01
INFO  tc.services.WorkflowStarter - Logged in
INFO  tc.services.WorkflowStarter - Finding Item Rev ... (ID=73020138/001)
INFO  tc.services.WorkflowStarter - Got ItemRevision 73020138/001
INFO  tc.services.WorkflowStarter - Instance Key : QzAAQs9Po13TJCAAAAAAAAAAAAA
INFO  tc.services.WorkflowStarter - Logging out
INFO  tc.services.WorkflowStarter - Logged out

 

 

  • This results in the following in Teamcenter;

000205.jpg

 

 

So I created the process as author.01 and the assignment list has directed the perform-signoffs to author.02, bypassing the select-signoff-team step as we filled the quorum.

 

 

Re: SOA API - How can I add a SignOff User to the Workflow?

Creator
Creator

Thanks for the detailed example. Unfortunately I can't setup an assignment list in our enviroment. 
Now I'm trying to approve the EPMSelectSignoffTask wich is added to my watchlist.

The questions is what is the supportingObject when I call workflowService.performActionWithSignature(...) 

The java doc says:

 

supportingObject - If the action is assign, provide a user or resource pool to assign the task. If the task is perform-signoff task, provide the Signoff object to set the decision. If the task is a perform-signoff task and the action is claim, provide the signoff object to be claimed.

 


I tried to that the ModelObject of the signoff user but without success.

 

 

Re: SOA API - How can I add a SignOff User to the Workflow?

Siemens Phenom Siemens Phenom
Siemens Phenom

If I read you correctly you have started a workflow, and you have a select signoff task in your inbox.

To move things on there are 3 things that you need to do;

  • Fill in the signoff profile for the task.
  • Set the task result to completed (like ticking adhoc-done).
  • Complete the select signoff task.

For the first part you can use addSignoffs a bit like the following;

final ModelObject[] signoff_profiles = epmTask.get_signoff_profiles();
CreateSignoffs createSignoff = new CreateSignoffs();
createSignoff.task = epmTask;

createSignoff.signoffInfo = new CreateSignoffInfo[signoff_profiles.length];
for (int idx = 0; idx < signoff_profiles.length; idx++) {
    ModelObject profile = signoff_profiles[idx];
    createSignoff.signoffInfo[idx] = new CreateSignoffInfo();
    createSignoff.signoffInfo[idx].originType = "SOA_EPM_SIGNOFF_ORIGIN_PROFILE";
    createSignoff.signoffInfo[idx].origin = profile;
    createSignoff.signoffInfo[idx].signoffAction = "SOA_EPM_Review";
    createSignoff.signoffInfo[idx].signoffMember = groupMember;
}

final ServiceData addSignoffsResponse = wfService.addSignoffs(new CreateSignoffs[]{createSignoff});

 

To set the task result you can use setProperties on the task;

// Set adhoc done
DataManagement.PropInfo propInfo = new DataManagement.PropInfo();
propInfo.object = epmTask;
propInfo.timestamp = epmTask.get_last_mod_date();
propInfo.vecNameVal = new DataManagement.NameValueStruct1[1];
propInfo.vecNameVal[0] = new DataManagement.NameValueStruct1();
propInfo.vecNameVal[0].name = "task_result";
propInfo.vecNameVal[0].values = new String[]{"Completed"};
final DataManagement.SetPropertyResponse setPropertyResponse = dmService.setProperties(new DataManagement.PropInfo[]{propInfo}, new String[0]);

Finally complete the task for the workflow to move on;

 

// Complete the task
Workflow.PerformActionInputInfo paii = new Workflow.PerformActionInputInfo();
paii.clientId = "complete" + epmTask.getUid();
paii.action = "SOA_EPM_complete_action";
paii.actionableObject = epmTask;
paii.propertyNameValues.put("comments", new String[]{"Auto Completed"});
paii.supportingValue = "SOA_EPM_completed";

ServiceData sd = wfService.performAction3(new Workflow.PerformActionInputInfo[]{paii});

Re: SOA API - How can I add a SignOff User to the Workflow?

Creator
Creator

Thanks! This si working perfectly. 

The only issue was to find a valid group member model object. 
It's not the user object.

My trick was to create create a workflow via RAC and than trace out the UID of the assigned group member. 

Than I loaded the group member by UID via DataManagement Service. 

Is there a way to create a group member object from the user object?