cancel
Showing results for 
Search instead for 
Did you mean: 

How to write WF script to retrieve field value in UDO

Former Member
0 Kudos

Hello Professionals,

We are trying to implement a simple workflow, to get a field value in user defined object. This value might be 0 or 1, if 0 the workflow will go in path and if 1 it will go in another path.

We have a problem in writing a script to get this value, we have tried several ways with no hope, there is no full document explaining how to write scripts with UDOs.

which class should I use, CurrentProcess.DataObject(UDO Name), or, CurrentProcess.B1Obj(UDO Name), after that, how can I read a specific field value?

Any help would be highly appreciated,

Thanks in advance

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Any updates?

CRVMANISH
Contributor
0 Kudos

Did you resolve this , we have same problem. Regards Manish

Former Member
0 Kudos

Yes, but be informed that the resolutions that I will mention might be illogical,

Our main issue was how to deal with UDOs in workflows,

From online samples we have successfully built this code block

var frozenType=Utility.getEnumValue(bp, "FrozenType", "tYES");

var validType=Utility.getEnumValue(bp, "ValidType", "tNO");

    var docUDOService = company.getGeneralService("upgradeform");

    var docUDO;

    var docUDOParam = docUDOService.getGeneralDataParam();

   

     var dobj=CurrentProcess.DataObject('dataObject1');  

    docUDOParam.put("DocEntry", dobj.getItem('Key'));

    docUDO = docUDOService.getByParams(docUDOParam);

 

    docUDO.put("U_Status", docUDO.get("Assigned to Team Leader"));

   

    docUDOService.update(docUDO);

This code used to change Status field in the upgradeform UDO to "Assigned to Team Leader".

Try to use this code, if it didn't work, and you got an error stating that service doesn't exist, delete your object, tables, and everything. Then, register it again but name it with lowercase letters, and make sure that Workflow services are stopped while you are registering the object.

After doing all of this, re-try the code and let me know what you got.

Good luck,

Former Member
0 Kudos

any updates?

Former Member
0 Kudos

I did a deep search to find any resource other than How to Configure workflow naive book with its Workflow APIs manual. I can't believe that there is no official material from SAP to cover Workflow Scripts to leverage the workflow usage.