Skip to main content
Question

Action Processor

  • November 21, 2022
  • 3 replies
  • 282 views

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.

3 replies

Forum|alt.badge.img+12
  • Hero (Customer)
  • 139 replies
  • January 11, 2023

​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 = [[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)][String]$myEnvironment,
    [Parameter(Mandatory = $true)][String]$myEventId ## Task Id
) 
Process {
	##set varibles
	$myCreds = New-Object System.Management.Automation.PSCredential ([USERNAME],[PASSWORD])
	$myGetTaskUri = "http://[INSERT 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://[INSERT 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.[INSERT 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://[INSERT 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" : [
            {
                "parameterName" : "[INSERT FIELD ID]",
                "parameterValue" : "TEST"
            },
            {
                "parameterName" : "stringValue",
                "parameterValue" : $newCustomFieldValue
            }
        ]
    }  
}
 

WilsonX
Sidekick (Employee)
Forum|alt.badge.img+6
  • Sidekick (Employee)
  • 23 replies
  • October 17, 2024
gravel-j wrote:

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 = [[ ACT_TYPE_SC == "COMMIT" ]],
activities = {
{ "new_action_ejb",
eventId = [[ PARENT_EVENT_ID ]],
fieldname = [[ ACT_DESC ]],
--actionedById = [[ lookup{"AssystUser", ACTIONING_USR_SC} ]],

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

},


Forum|alt.badge.img+5
  • Do Gooder (Customer)
  • 16 replies
  • November 19, 2024

You could also probably accomplish this with a LUA script that executes SQL to update the required field


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings