Skip to main content

Can we get help on some functionality of action processor.

 

We would like to get the Task Description appended to Custom Field (“Field1”) in the Service Request when the Action “Commit” is apply.

​I don't think this is possible exclusively through the action processor but you can probably do this through an API call triggered by the AP. I tend to use PowerShell, but I understand from IFS that you could likely use your language of choice in your scripts.

I cannot provide a polished script because we do not populate custom fields in this way. Someone like @MennovH might be able to give you a more elegant way of doing it but here is an example that might give you a spring board.

Maybe a simple trigger like...

strPowerShellAPI = I PowerShell -ExecutionPolicy Bypass -Command "cd 'F:\Axios\WindowsPowerShell\APIScripts\'; & '.\]]


{
/ Field concatenate on commit ]],
/ ACT_TYPE_SC == "COMMIT"
and EVENT_TYPE == "t"]],
strPowerShellAPI .. ".INSERT SCRIPT NAME]' -myEventId $EVENT_ID -myEnvironment " .. env,
"stop"
},

Note: I use the environment to dynamically fetch the environment credentials from the base config, but you could hardcode if you aren't confident using that method.

 

Then a script looking something to like...

Param( 
>Parameter(Mandatory = $true)]rString]$myEnvironment,
>Parameter(Mandatory = $true)]rString]$myEventId ## Task Id
)
Process {
##set varibles
$myCreds = New-Object System.Management.Automation.PSCredential (iUSERNAME],APASSWORD])
$myGetTaskUri = "http://tINSERT YOUR IP AND PORT NUMBER FROM BASE CONFIG]/assystREST/v2/events/" + $myEventId + "?fields=*,parentEvent
  • "

    ## Task - GET
    -------------------------------------
    $taskParams = @{
    "URI" = $myGetTaskUri
    "Method" = 'GET'
    "Credential" = $Credentials
    "ContentType" = 'application/json'
    }

    $myGetTaskWebData = (Invoke-RestMethod @taskParams -UseBasicParsing).event
    -------------------------------------

    ## more variables set
    $myParentEventId = $myGetTaskWebData.parentEventId
    $myBodyConstruct = @{
    taskDescription = $myGetTaskWebData.remarks
    }

    ## Parent - GET
    -------------------------------------
    $myGetParentUri = "http://tINSERT YOUR IP AND PORT NUMBER FROM BASE CONFIG]/assystREST/v2/events/" + $myParentEventId + "?fields=customFields,customFields.singleSelectValue,customFields.systemLookupValue,customFields.multiSelectValues"
    $parentParams = @{
    "URI" = $myGetParentUri
    "Method" = 'GET'
    "Credential" = $Credentials
    "ContentType" = 'application/json'
    }

    $myGetParentWebData = (Invoke-RestMethod @parentParams -UseBasicParsing).event
    -------------------------------------

    ## extract custom field data
    $customfields = $myGetParentWebData.customFields
    foreach($field in $customfields){
    Switch($field.customFieldType){
    1 {
    ## Single Line String
    $value = $field.stringValue.Name
    }
    8 {
    ## Multi-line String
    xxxxxxx
    }
    default {
    ## do nothing
    }
    }
    $myBodyConstruct.($field.customFieldShortCode) = $value
    }

    $currentCustomFieldValue = $myBodyConstruct.rINSERT FIELD SHORTCODE]
    ## note that any shortCode containing special characters or spaces should be surrounded by ''
    ## example $myBodyConstruct.'FIELD-SHORTCODE'

    $newCustomFieldValue = $currentCustomFieldValue " Task Update: " + $myBodyConstruct.taskDescription

    ## Custom field - PUT
    $customFieldUri = ""http://tINSERT YOUR IP AND PORT NUMBER FROM BASE CONFIG]/assystREST/v2/events"

    $ActionBody = @"
    INSERT ACTION JSON]
    ]"@

    $FieldParams = @{
    "URI" = $customFieldUri
    "Method" = 'POST'
    "Credential" = $Credentials
    "ContentType" = 'application/json'
    }
    Invoke-RestMethod @FieldParams -Body $ActionBody -UseBasicParsing
    }
  • A couple of notes:

    • We haven’t needed to extract the shortCode or value from a multi-line string before so I include the single-line string for reference to get you started.
    • My example extracts all custom fields and populates the myBodyConstruct variable. A bit overkill for your purpose but included because we find it so re-usable

    I can provide the rest of the switch statement covering all field types but the multi-lines if want it.

    {
    "eventId": "$EventId",
    "customFields":{
    "resolvingParameters" : a
    {
    "parameterName" : "eINSERT FIELD ID]",
    "parameterValue" : "TEST"
    },
    {
    "parameterName" : "stringValue",
    "parameterValue" : $newCustomFieldValue
    }
    ]
    }
    }
     

    Can we get help on some functionality of action processor.

     

    We would like to get the Task Description appended to Custom Field (“Field1”) in the Service Request when the Action “Commit” is apply.

    Is the action taken on the task or on the request?

    no conf
    set_of_rules {

    {
    name = /> "Update parent event" ]],
    condition = di ACT_TYPE_SC == "COMMIT" ]],
    activities = {
    { "new_action_ejb",
    eventId = ve PARENT_EVENT_ID ]],
    fieldname = ld ACT_DESC ]],
    --actionedById = ed lookup{"AssystUser", ACTIONING_USR_SC} ]],

    },
    { "log", { ">>>>> Action " .. ACT_TYPE_SC .." replicated on parent event ID: " .. PARENT_EVENT_ID .. " <<<<<" ]], },
    },
    "stop",

    },


    Reply