Is there a way to get the process model ID from its UUID?...

Is there a way to get the process model ID from its UUID?...

OriginalPostID-127577

OriginalPostID-127577

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer
    in reply to Jason Ruvinsky
    In that case then, I think you just need to use the process model details by uuid plugin function to get the pmid at call time - would this work within the configuration of the start process node?
  • 0
    Certified Senior Developer
    in reply to Mike Schmitt
    Mike, using the Process Model Details by UUID plugin function would work, but since the data is returned in a formatted string, rather than in a dictionary, I'd need to extract the ID from it using string parsing. This seems like a really round-about and potentially error prone method of obtaining the ID. I could look into writing a simple plugin that gets it, if one doesn't already exist.

    Also, I tested the Start Process Node with an integer ID, and that does work for calling the matching process with that ID.
  • 0
    Certified Lead Developer
    in reply to Jason Ruvinsky

    I agree with your critique regarding the data returned by the plugin expression, and for that reason I've already written an expression rule in the past that does the needed parsing and passes back a dictionary. I can post it tomorrow if you need, as I'm travelling today.

    Edit: I'm back today, so here's the expression rule I mentioned in case anyone would like to use it.

    =/*  GLBL_processModelDetailsByUUID  */
    
    with(
      local!rawText: if(
        rule!APN_isBlank(ri!uuid),
        " ",
        getprocessmodeldetailsbyuuid(ri!uuid)
      ),
    
      local!type: extract(local!rawText, "Type:", "," ),
      local!nameList: trim( split( extract( rawText, "Name: [", "]" ), "," )),
      local!nameArray: apply( rule!GLBL_returnLanguageNamePair, local!nameList ),
      local!id: extract( local!rawText, "Id:", ", UUID" ),
      local!uuid: extract( local!rawText, "UUID:", ", Creator" ),
      local!creator: extract( local!rawText, "Creator: ", ", Last" ),
      local!lastModifiedBy: extract( local!rawText, "Last Modified by: ", ", Parent"),
      local!parent: extract( local!rawText, "Parent: ", ", Parent Id:" ),
      local!parentId: tointeger( extract( local!rawText, "Parent Id: ", "," )),
      local!location: extract( local!rawText, "Location: ", ", Is" ),
      local!isPublic: extract( local!rawText, "IsPublic: ", ", Created" ) = "true",
      
      /* note: for the latest versions of the content details by uuid plugin, 
        the following lines can have the expression rule call replaced with 
        a simple "todatetime()" function, as the plugin was upgraded to 
        return a more standard datetime string after this handler rule was
        originally written. */
      local!createdOn: rule!GLBL_dateTimeStringToDatetime(extract( local!rawText, "Created on: ", ", Last" )),
      local!lastModifiedOn: rule!GLBL_dateTimeStringToDatetime(extract( local!rawText & "END", "Last Modified on: ", "END" )),
      
      {
        type: local!type,
        primaryName: property(index(local!nameArray, 1, ""), "name", ""),
        nameArray: local!nameArray,
        id: local!id,
        uuid: local!uuid,
        creator: local!creator,
        lastModifiedBy: local!lastModifiedBy,
        parent: local!parent,
        parentId: local!parentId,
        location: local!location,
        isPublic: local!isPublic,
        createdOn: local!createdOn,
        lastModifiedOn: local!lastModifiedOn
      }
    )
    
    /* developed by: Mike Schmitt */

  • 0
    Certified Lead Developer
    in reply to Jason Ruvinsky

    Hi  . I have to implement the same. can you let me know what approach have you choose?

  • 0
    Certified Lead Developer
    in reply to Mike Schmitt

    Hi  , what's the rule!GLBL_returnLanguageNamePair?

  • 0
    Certified Lead Developer
    in reply to yashig2399
    Any reason you don't create constants of type "Process Model", which are fine being exported/imported to different environments and can be used directly in the smart service?

    I think this is still a valid question.

  • 0
    Certified Lead Developer
    in reply to yashig2399

    The comment you're replying to is over 7 years old now. I don't have access to the same version of that rule anymore, as I originally wrote it several projects ago at least.

    I have a modern iteration of the same essential rule and in it, instead of bending over backwards to iterate across potential different-language process model name versions, I merely extract the english one directly.  (The rule you were asking about probably takes an array of name/value pairs and returns them in a better fashion, given that we didn't even have a!forEach() yet when this old version was written).

    Here's my new version with no precedents, just for the sake of anyone who might find this thread in the future.  Note that I've upgraded it to make use of the updated Content Tools plug-in, and to consume either PM ID or PM UUID (the plugin function can use either).

    a!localVariables(
      local!initialResult: getprocessmodeldetailsbyuuid(
        processModelUUIDOrId: a!defaultValue(
          value: ri!pmId,
          default: a!defaultValue(
            value: ri!pmUuid,
            default: null()
          )
        )
      ),
    
      local!foundPmId: index(extract(local!initialResult, " Id:", ", UUID:"), 1, null()),
    
      if(
        a!isNotNullOrEmpty(local!foundPmId),
        a!map(
          pmId: local!foundPmId,
          uuid: index(extract( local!initialResult, "UUID:", ", Creator:" ), 1, null()),
          name: index(extract( local!initialResult, "Name: [en_US=", "], Id:" ), 1, null()),
          folderName: index(extract( local!initialResult, "Parent: ", ", Parent Id:" ), 1, null()),
          folderId: tointeger(index(extract( local!initialResult, "Parent Id: ", ", Location:" ), 1, null())),
          createdBy: index(extract( local!initialResult, "Creator: ", ", Last Modified" ), 1, null()),
          createdOn: todatetime( index(extract( local!initialResult, "Created on: ", ", Last Modified on:" ), 1, null())),
          modifiedBy: index(extract( local!initialResult, "Last Modified by: ", ", Parent:" ), 1, null()),
          modifiedOn: todatetime( index(extract( local!initialResult, "Last Modified on: ", ", Number" ), 1, null()) ),
          path: index(extract(local!initialResult, "Location: ", ", IsPublic" ), 1, null()),
          version: tointeger(index(extract( local!initialResult & "|END", "Number of Versions: ", "|END" ), 1, null()))
        ),
        
        a!map(
          result: "No Process Model Found"
        )
      )
    )

    Example output when fed a valid PM ID or UUID:

  • 0
    Certified Senior Developer
    in reply to yashig2399

    Our use case is special because we have one shared development environment, but two separate production environments that house different applications. The constant was part of a common object (LDAP Sync post sync processes) that goes to both environments, but needed to call different processes depending on which production environment it lived on. I had to create multiple versions of this application, with the settings for each target environment. I renamed the app for each with the environment name in it, so it is easy to tell them apart. When making changes, I need to import into dev each, make the changes to the process model constants (and other changes that have dependencies on different apps), and then export again / re-import the dev version. This is all very closely tied to our setup and use case, however, and may not apply to you.