SAMPLE SCRIPT FILE FOR ADDING APPROVERS THROUGH CUSTOM TRIGGER

 

import sys
import json
import urllib
 
file_Path = sys.argv[1]
 
with open(file_Path) as data_file:
data = json.load(data_file)
requestObj = data['request']
 
detailsJSON1={}
detailsJSON1['requester']=requestObj['REQUESTER']
 
 
resultjson={}
resultjson["operation"] = []
resultjson["result"]="success"
message = "Sample Python script for adding approvers"
resultjson["message"]=message
 
operationJson={"INPUT_DATA":[]}
operationJson["OPERATIONNAME"]="ADD_APPROVAL_STAGE"
approvalArray={}
approvalArray1={}
approvalArray2={}
 
 
if "Howard" in detailsJSON1['requester']:


approvalObject="heather.graham@xyz.com"
approvalArray={"StageOne":[]}
approvalArray['StageOne'].append(approvalObject);
operationJson['INPUT_DATA'].append(approvalArray)
 
approvalObject1="jeniffer.doe@xyz.com"
approvalArray1={"StageTwo":[]}
approvalArray1['StageTwo'].append(approvalObject1);
operationJson['INPUT_DATA'].append(approvalArray1)
 

else: 
if "Jeniffer" in detailsJSON1['requester'] :

approvalObject="howard.stern@xyz.com"
approvalArray={"StageOne":[]}
approvalArray['StageOne'].append(approvalObject);
operationJson['INPUT_DATA'].append(approvalArray)
 
approvalObject1="heather.graham@xyz.com"
approvalArray1={"StageTwo":[]}
approvalArray1['StageTwo'].append(approvalObject1);
operationJson['INPUT_DATA'].append(approvalArray1)
 
 
else:
if "John" in detailsJSON1['requester'] :

approvalObject="howard.stern@xyz.com"
approvalArray={"StageOne":[]}
approvalArray['StageOne'].append(approvalObject);
operationJson['INPUT_DATA'].append(approvalArray)
 
approvalObject1="heather.graham@xyz.com"
approvalArray1={"StageTwo":[]}
approvalArray1['StageTwo'].append(approvalObject1);
operationJson['INPUT_DATA'].append(approvalArray1)
 
approvalObject2="jeniffer.doe@xyz.com"
approvalArray2={"StageThree":[]}
approvalArray2['StageThree'].append(approvalObject2);
operationJson['INPUT_DATA'].append(approvalArray2)
 
resultjson['operation'].append(operationJson)
 
print(resultjson)

 




ServiceDeskPlus - 帮助台和资产管理软件
Copyright © 2006-2017 卓豪(北京)技术有限公司版权所有