Setting System Data's ProcessID - is it possible?

Comments

10 comments

  • Official comment
    Avatar
    Yaniv Levi

    Hi Victor,

    2 more options to consider:

    1. As you mentioned you're uploading the files to SharePoint, then, you can just add another column (metadata item) to your library to hold the proc reference (i.e ProcessID GUID). Than, as part of the process model, loop over the files (items) and update this column with the ${ProcessID}.  You can set this column as part of your index so you can search by it if this is part of your intention.

    1. BTW - as mentioned by Alexey, in addition to the above, would just use a self generated unique id to be used for both instance/form data and folder - i.e Request ID, and would use a more readable ID than GUID like a sequence number.

    2. If you have option/resource to write some code, than you can implement custom StartTask proxy page (i.e ASP.NET page), which will allow you to self manage and control the ProcessID as well as to run the StartTask within the process itself (that is, after the process has already been initiated). Here is a pseudo code of it:

    • Get the process to be initiated from the QueryString
    • Initiate the process using the CreateProcInst API - you can generate your own Process Instance ID (ProcessInstID) and WorkObjectID (WorkObjID) etc and pass it on to the process to use them. You can also pass him with initial attributes values using the Attributes (including form fields values etc)
    • "Wait" for process to start and assign the first task (your StartTask) and get the TaskID (WorkItemID)
    • NOTE - the "wait" can be impletemted in many ways, from as simple as a "pull loop" for the task and to more advance pub/sub patterns by subscription to the event of assign work item...
    • Redirect your user to the StartTask, which is now just a TaskForm (that is a form of a task inside a running process instance) i.e https://[portal instance URL]/appbuilder/FormRender?WID=[retrieved task id here]

    With the above option:

    • For the user to get its StartForm, he'll use the custom ASP.NET page url, i.e https://[hosting server]/StartTaskProxy.aspx?Process=[Your process name here]
    • NOTE - You need to make sure that this page is hosted under windows integrated authentication - so you can get the requesting user and pass it to the CreateProcInst as the ProcessInitiator.
    • User will eventually be redirected to https://[portal instance URL]/appbuilder/FormRender?WID=[retrieved task id here]
    • Now, inside the StarForm, you'll have the ProcessID and you can use it for uploading the files and any other.

     

    This, as mentioned is just a high level pseudo code and food for thoughts. Implementation can be done in many ways, from very simple to more advanced and slightly complex. In addition, you can implement using any tools, language and runtime of your choosing, i.e ASP.NET, php, python and more - just keep in mind that the purpose of this this is to be used as a proxy page as thus it need to run server side and not client side.

    If you only need this as a one time usage for a this specific process - than would go with the simple option provided in #1 and earlier posts. If on the other hand, you'll need to over many process and/or for a  business critical application, than you can consider #2.

    BTW - if you go with the temp folder and then move file option, than you can also update the new location of the files as part of the process model itself, this should be a better option, as if done with JavaScript, this can only be done in the form, and as such can only be done when one of the following TaskForm will be opened:

    • You'll need to implement the code as part of the onFormLoadComplete
    • You'll need to be able to identify if data was already update and if not then update, while it yes "return".

    If you have more than one file uploaded - just use the loop to loop over the files and update the required file properties.

    Thanks,

    Yaniv.

     

     

    Comment actions Permalink
  • Avatar
    AgilePoint NX Support

    Victor,

     

    We understand your requirement. 

    The Form submit to create an instance does not accept Process instance ID. However the REST API's for Created Process instance would give full control of the Instance information to the user's custom code.

    Reference: https://documentation.agilepoint.com/11/developer/restmethodCreateProcInst.html

    Will it be possible for you to split the design the form submit into two steps, when in the second step the Form for uploading the files to SharePoint will be as Task and not as Start Task which will satisfy your use case.

     

    Thank you

    AgilePoint NX Support

    0
    Comment actions Permalink
  • Hi Victor,

    we had the same requirement earlier and did following: we create a textbox where we save a temp generated GUID. After that we upload files under the folder with that GUID and after the form (in process modell) we transfer files from temp folder to the folder with process ID. 

    Regards

    Alexey

    0
    Comment actions Permalink
  • Avatar
    Cutting, Victor

    Thanks for the replies.

    The second part of my question would have been: once you've moved the files to the subfolder in the process, how do you then attach the files back to the attachment control so that the users receiving the subsequent approval forms will see them in the eForm, with the files in their "new" location, and be able to click on them to open them and review? Cheers

    0
    Comment actions Permalink
  • Hi Victor,

     

    you can do this in process modell by changing the url, encrypted url and name i guess in the file upload. Just check the values in manage where you have that GUIDs. Unfortunately this won't work if you have multiple files. In taht case you would need to change all file paths with JS in form.

     

    Regards

    Alexey

    0
    Comment actions Permalink
  • Avatar
    Cutting, Victor

    ok yes i will try that with the javascript. Thanks so much!

    0
    Comment actions Permalink
  • Yaniv,
    How would you update the file upload fields with multiple files using loop? With loop you can read data, but not update...
    Regards
    Alexey

    0
    Comment actions Permalink
  • Avatar
    Yaniv Levi

    Hi Alexey,

    There are few options, but for the most will use the following:

    • Use the Update Process Data activity.
    • In the Process Data Variable just use the xpath and include the index, for sample (using subform data): /pd:AP/pd:formFields/pd:sfExpenseItems_SubForm[nIndex]/pd:sfExpenseItems

    Have not need this use it for a while, but with older version - used this many times.

    Thanks,

    Yaniv.

    0
    Comment actions Permalink
  • Hi Yaniv,
    i thought there is another way to do that rather then that... still thank you!
    Regards
    Alexey

    0
    Comment actions Permalink
  • Avatar
    Loren Bratzler

    I will add that it is not quite as simple as just plugging in an index number in the Process Data Variable field.  Here is a forum post from a couple of years ago that talks about this.  About half-way down the topic is a post from a guy named Mario where he explains how to "hack" the Process Data Variable and index it:

    https://helpdesk.agilepoint.com/hc/en-us/community/posts/360020892494-Can-you-Modify-Subform-data-not-just-use-it-inside-a-loop-

    I have used this approach in a few applications.  I will say, however, that AgilePoint support has told me that they do not recommend using this "hack" but unfortunately, it is the only way I know of to be able to update repeating data elements.  AgilePoint really needs to develop an activity for doing this or enhance the "Update Process Data" activity to be able to do this.

    0
    Comment actions Permalink

Please sign in to leave a comment.