ServiceDesk Plus

    SAMPLE SCRIPT FILE FOR SETTING APPROVER STAGE 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']

    detailsJSON1['subject']=requestObj['SUBJECT']

    detailsJSON1['description']=requestObj['SHORTDESCRIPTION']

    detailsJSON1['priority']=requestObj['PRIORITY']

    detailsJSON1['status']=requestObj['STATUS']

     

     

    resultjson={}

    resultjson["operation"] = []

    resultjson["result"]="success"

    message = "Sample Python script for set_approval_stage"

    resultjson["message"]=message

     

    operationJson={"INPUT_DATA":[]}

    operationJson["OPERATIONNAME"]="SET_APPROVAL_STAGE"

    operationJson["send_immediately"]="true"

    notesArray={}

    notesArray1={}

    notesArray2={}

     

     

    if "swetha" in detailsJSON1['requester']:

    noteObject="sampleuser1@sdplinmail.com"

    notesArray={"StageOne":[]}

    notesArray['StageOne'].append(noteObject);

    operationJson['INPUT_DATA'].append(notesArray)

     

    noteObject1="sampleuser2@sdplinmail.com"  

                                                 

    notesArray1={"StageTwo":[]}

    notesArray1['StageTwo'].append(noteObject1);

    operationJson['INPUT_DATA'].append(notesArray1)

     

    noteObject2="sampleuser3@zohocorp.com"   

    notesArray2={"StageThree":[]}

    notesArray2['StageThree'].append(noteObject2);

    operationJson['INPUT_DATA'].append(notesArray2)

     

    else

    if "Howard" in detailsJSON1['requester'] :

    noteObject="sampleuser1@sdplinmail.com"                                                

     

    notesArray={"StageOne":[]}

    notesArray['StageOne'].append(noteObject);

    operationJson['INPUT_DATA'].append(notesArray)

     

    noteObject1="sampleuser1@sdplinmail.com"                                                

     

    notesArray1={"StageTwo":[]}

    notesArray1['StageTwo'].append(noteObject1);

    operationJson['INPUT_DATA'].append(notesArray1)

     

    noteObject2="sampleuser1@sdplinmail.com"                                                

     

    notesArray2={"StageThree":[]}

    notesArray2['StageThree'].append(noteObject2);

    operationJson['INPUT_DATA'].append(notesArray2)

     

     

     

    else:

    if "John" in detailsJSON1['requester'] :

    noteObject="sampleuser1@sdplinmail.com"                                                

     

    notesArray={"StageOne":[]}

    notesArray['StageOne'].append(noteObject);

    operationJson['INPUT_DATA'].append(notesArray)

     

    noteObject1="sampleuser1@sdplinmail.com"                                                

     

    notesArray1={"StageTwo":[]}

    notesArray1['StageTwo'].append(noteObject1);

    operationJson['INPUT_DATA'].append(notesArray1)

     

    noteObject2="sampleuser1@sdplinmail.com"                                                

     

    notesArray2={"StageThree":[]}

    notesArray2['StageThree'].append(noteObject2);

    operationJson['INPUT_DATA'].append(notesArray2)

     

     

     

    resultjson['operation'].append(operationJson)

     

    print(resultjson)

     

    Copyright © 2017, ZOHO Corp. All Rights Reserved.