Wikis - Page

Scipt or orchestration to update parent(s) relational field to include child

0 Likes

I have two applications - a library of items (the parent) and a check-out (the child). A child can check out multiple parents, and I have a transition action to put the parent in a "Requested" state. Then, the parents need to be manually updated to include the child in a single relational field before the parent is checked out. The "check-out" transition executes an action to transition the child to an "In use" state. This is problematic because if any one parent transitions the child, the other parent is also transitioned, but does not have the child reference and is difficult to find and update. Once the child is finished with the parents, a child "Check-in" transition action returns the parents back to the librarian for review. In the review for each parent, the child must be manually moved from a single relational to a multi-relational to show the check-out history for the parent.

I want to automate this process but I am not a JavaScript coder, and the orchestrations are too complicated to figure out how to make them work. In other applications, I have used post-type transitions to map fields from one application to another, but in this case, a post-type transition is not the right move. I don't want the child to create new parents, nor do I want to create a child from multiple parents (which results in multiple children per parent). I need a lot of help here, so I hope someone has done something similar and can provide me with a full example.

Labels:

How To-Best Practice
Comment List
  • Erika,

    Thank you so much. This is definitely going to help me learn. I am using a relational grid to avoid the scenario you identified. Also, I wasn't clever enough to put both applications within the same project, so can the orchestration reach across project boundaries? EIther that, or I need to bite the bullet and recreate one of the applications within the other project. Either way is fine.

    I do have one additional favor to ask. We haven't upgraded to 12.2 SBM yet. We are still on 11.8. Is it possible for you to downgrade the version on the example so I can import it. 

  • Hi Dwayne, I agree, an orchestration is a good option for automated this process.  In fact, the orchestration needed is probably a good learning example to get acquainted with them.  If I understand correctly what you are trying to do you are just going through each selected parent item and making some field updates.  I put together a sample blueprint.  There are two orchestrations needed that look like this: 

    I have attached a blueprint with the example containing the orchestrations.  In my example, I created several records in the Document management workflow for the library, then I created a document request in the child workflow where you select one or more of the parent records.  The orchestration then goes through the list of selected parent items and transitions them, and during that transition it updates the single relation to point to the child workflow.  The check-n transition when executed from the child workflow goes through each of the parent records again and transitions them and sets the child record value in a multi-relational field and then puts the parent record back to the New state via a transition action where the single relational field value is cleared and set the parent record up to be selected again.  
    As I type this out, thinking about a usage scenario, would there be a use case where more than one child request is requesting a parent document from the library?  That could affect the transitions that are executed in your orchestration and cause errors.  To solve that, I would recommend a relational grid that filters the items based upon the state field in the parent document workflow to only show items available for check out. 

    Let me know if this sounds like it would meet your needs.  I can provide some more explanation for the orchestration configuration.

    Document Management.zip

  • David, I hope you had a good Christmas and New Years Holiday. 

    Do you happen to have any additional details for your suggestions? I really do believe that the orchestration can be made to work, but it is really cryptic to get the coding/mapping correct. 

  • David,

    Thank you for the information. Is there a tutorial or something on how to do the mapping? I am not sure which of the mapping items to focus on or how to tell the web service to look at the MR field in the child. I currently have a transition action that transitions the parent without mapping. 

    And I found an example AppScript that I modified to read the "Current Test" field value and I think concatenate the string with the string from "History" field. Maybe it's not completely correct though.

     

    ' ---------------------------------------
    ' This script reads from a field and writes its value to another field.
    '
    ' Requirements:
    ' This script relies on Shell.Item, which only exists in pre-transition,
    ' post-transition, pre-state, and post-state contexts.
    '
    ' Note: if reading a drop-down list field, do not use the GetFieldValue()
    ' function. Instead, retrieve the actual Field object, and use its
    ' GetDisplayValue() method.
    ' Require all variables to be declared before use Option Explicit
    ' MODIFY THESE CONSTANTS FOR YOUR DATABASE
    ' ----------------------------------------
    ' Names of the fields we will work with
    const FLDNAME_SRC = "Current Check-out Log Item"
    const FLDNAME_DEST = "Check-out Log History"
    ' Find the item being transitioned
    If Ext.ShellHasProp( "Item" ) Then
      ReadWriteFields
    Else
      ' There is no current item, so write a message to the event viewer
      Call Ext.LogErrorMsg( "SBM AppScript error: Shell.Item does not exist." )
    End If
    ' Read from one field, write back to another field
    Sub ReadWriteFields()
      Dim fldValue1, fldValue2, QUOTE
      QUOTE = Chr( 34 )  ' the only way to get a quote in VBScript
      ' Read from the source field
      If Not Shell.Item.GetFieldValue( FLDNAME_SRC, fldValue1 ) Then
        ' Error finding the field or reading from it
        Call Ext.LogErrorMsg( "Cannot read from field " _
          & QUOTE & FLDNAME_SRC & QUOTE )
        Exit Sub
      End If
    'Read from Destination field to concatenate with Source field
      If Not Shell.Item.GetFieldValue( FLDNAME_DEST, fldValue2 ) Then
        ' Error finding the field or reading from it
        Call Ext.LogErrorMsg( "Cannot read from field " _
          & QUOTE & FLDNAME_SRC & QUOTE )
        Exit Sub
      End If
      ' Combine the data, return is csv string, so concatenate them
    	fldValue = fldValue1 & "," & fldValue2
      ' Write to the destination field
      If Not Shell.Item.SetFieldValue( FLDNAME_DEST, fldValue ) Then
        ' Error finding the field or writing to it
        Call Ext.LogErrorMsg( "Cannot write to field " _
          & QUOTE & FLDNAME_DEST & QUOTE )
        Exit Sub
      End If
    End Sub

  • Hi Dwayne,  Without orchestrations or scripts, you can have the child transition call one or more web service actions to transition the parent(s).  You would use a web service function Transition Item.  Map the child id into parent's single relational field.  On "Check-In", the child would again calla the transition item web service to transition the parent updating the parent's single relational field to empty and adding the Child record to the MR field.  In this Check-In transition, a second web service transition action will probably exist to update the child to remove the parent item from the child after the parent has been updated.

    When you add the web service action, you will need to add a link to the web service WSDL that contains the definition for TransitionItem.  The link to this WSDL is http://yourserver.domain.com/gsoap/sbmappservices72.wsdl.

Related
Recommended