All Classes Namespaces Functions Properties Pages
Web Service Call using JSON

This page describes how to call a TotalAgility web service from jquery using JSON.


Calling UserService


Method: LogOnWithPassword2()
1 <html>
2 <body>
3  <header>
4  <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
5  </header>
6  <div id="Request"></div>
7  <div id="Result"></div>
8  <script>
9  var LogonWithPasswordStruct = function () {
10  var struct = {
11  "userIdentityWithPassword": {
12  "LogOnProtocol": "",
13  "UnconditionalLogOn": false,
14  "UserId": "",
15  "Password": ""
16  }
17  };
18  return struct;
19  };
20 
21 
22  var logonJSON = new LogonWithPasswordStruct();
23  logonJSON.userIdentityWithPassword.LogOnProtocol = "7";
24  logonJSON.userIdentityWithPassword.UnconditionalLogOn = true;
25  logonJSON.userIdentityWithPassword.UserId = "User1";
26  logonJSON.userIdentityWithPassword.Password = "xxxxxxxxxx";
27 
28  $("#Request").html("<BR/><B>Request:</B><BR/>" + JSON.stringify(logonJSON));
29 
30  // Calling method LogOnWithPassword2
31  $.ajax({
32  type: "POST",
33  async: "false",
34  url: "http://localhost/TotalAgility/Services/Sdk/UserService.svc/json/LogOnWithPassword2",
35  data: JSON.stringify(logonJSON),
36  contentType: "application/json; charset=utf-8",
37  crossDomain: true,
38  dataType: "json",
39  success: function (result) {
40  $("#Result").html("<BR/><B>Response: </B><BR/>" + JSON.stringify(result.d));
41  },
42  error: function (jqXHR, textStatus, errorThrown) {
43  alert("***Error***\n");
44  }
45  });
46 
47  </script>
48 </body>
49 </html>

Method: Logoff()
1 <html>
2 <body>
3  <header>
4  <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
5  </header>
6  <div id="Request"></div>
7  <div id="Result"></div>
8  <script>
9  var LogOffStruct = function () {
10  var struct = {
11  "sessionId": null
12  };
13  return struct;
14  };
15 
16 
17  var logOffJSON = new LogOffStruct();
18  logOffJSON.sessionId = "B1B44E3109E6447BB4EEBA578937402B";
19 
20  $("#Request").html("<BR/><B>Request:</B><BR/>" + JSON.stringify(logOffJSON));
21 
22  // Calling method Logoff
23  $.ajax({
24  type: "POST",
25  async: "false",
26  url: "http://localhost/TotalAgility/Services/Sdk/UserService.svc/json/LogOff",
27  data: JSON.stringify(logOffJSON),
28  contentType: "application/json; charset=utf-8",
29  crossDomain: true,
30  dataType: "json",
31  success: function (result) {
32  $("#Result").html("<BR/><B>Response: </B><BR/>" + JSON.stringify(result.d));
33  },
34  error: function (jqXHR, textStatus, errorThrown) {
35  alert("***Error***\n");
36  }
37  });
38 
39  </script>
40 </body>
41 </html>

Calling JobService


Method: CreateJob()
1 <html>
2 <body>
3  <header>
4  <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
5  </header>
6  <div id="Request"></div>
7  <div id="Result"></div>
8  <script>
9  var InputVariableStruct = function () {
10  var struct = {
11  "DisplayName": "",
12  "Id": "",
13  "Value": "",
14  "VariableType": {
15  "FormattedAsText": null,
16  "Value": ""
17  }
18  };
19 
20  return struct;
21  };
22 
23  var CreateJobStruct = function () {
24  var struct = {
25  "jobInitialization": {
26  "InputVariables": [],
27  "StartDate": null,
28  },
29  "processIdentity": {
30  "Id": "",
31  "Name": "",
32  "Version": 0
33  },
34  "sessionId": ""
35  };
36 
37  return struct;
38  };
39 
40 
41  var createJobJSON = new CreateJobStruct();
42 
43  var varFirstName = new InputVariableStruct();
44  varFirstName.DisplayName = "FirstName";
45  varFirstName.Id = "FIRSTNAME";
46  varFirstName.Value = "Naresh"; // string
47  createJobJSON.jobInitialization.InputVariables.push(varFirstName);
48 
49  var varLastName = new InputVariableStruct();
50  varLastName.DisplayName = "LastName";
51  varLastName.Id = "LASTNAME";
52  varLastName.Value = "Kokkula"; // String
53  createJobJSON.jobInitialization.InputVariables.push(varLastName);
54 
55  var varLoanApplied = new InputVariableStruct();
56  varLoanApplied.DisplayName = "LoanApplied";
57  varLoanApplied.Id = "LOANAPPLIED";
58  varLoanApplied.Value = "2016-01-05T10:19:00.000Z"; //Date
59  createJobJSON.jobInitialization.InputVariables.push(varLoanApplied);
60 
61  var varAmountRequired = new InputVariableStruct();
62  varAmountRequired.DisplayName = "AmountRequired";
63  varAmountRequired.Id = "AMOUNTREQUIRED";
64  varAmountRequired.Value = 25000.00; // Decimal
65 
66  createJobJSON.jobInitialization.InputVariables.push(varAmountRequired);
67  createJobJSON.processIdentity.Id = "F296FF6FC8794410BAA627093A8A74D3";
68  createJobJSON.processIdentity.Name = "BP";
69  createJobJSON.processIdentity.Version = 0;
70  createJobJSON.sessionId = "3F05A05532EA469D8F9FC150A61D5CBB";
71 
72  $("#Request").html("<BR/><B>Request:</B><BR/>" + JSON.stringify(createJobJSON));
73 
74  // Calling method CreateJob
75  $.ajax({
76  type: "POST",
77  async: "false",
78  url: "http://localhost/TotalAgility/Services/Sdk/JobService.svc/json/CreateJob",
79  data: JSON.stringify(createJobJSON),
80  contentType: "application/json; charset=utf-8",
81  crossDomain: true,
82  dataType: "json",
83  success: function (result) {
84  $("#Result").html("<BR/><B>Response: </B><BR/>" + JSON.stringify(result.d));
85  },
86  error: function (jqXHR, textStatus, errorThrown) {
87  alert("***Error***\n");
88  }
89  });
90 
91  </script>
92 </body>
93 </html>

Method: CreateJobWithDocumentsAndProgress2()
1 <html>
2 <body>
3  <header>
4  <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
5  </header>
6  <div id="Request"></div>
7  <div id="Result"></div>
8 
9  <script>
10 
11  var CreateJobWithDocumentsAndProgress2Struct = function () {
12  var struct = {
13  "jobWithDocsInitialization": {
14  "InputVariables": null,
15  "RuntimeDocumentCollection": [],
16  "StartDate": null
17  },
18  "processIdentity": {
19  "Id": "", // required
20  "Name": "", // required
21  "Version": 0.0 // required
22  },
23  "variablesToReturn": [],
24  "sessionId": "" // required
25  };
26  return struct
27  };
28 
29  var RuntimeDocument = function () {
30  var rtd = {
31  "Base64Data": null, //alternate to passing 'Data'
32  "Data": null, //required byte array, JS Array i.e. [73,73,14 ...] (not Unit8)
33  "DeleteDocument": false,
34  "DocumentGroup": null,
35  "DocumentTypeId": null,
36  "DocumentTypeName": null,
37  "FieldsToReturn": [], //RunTimefieldIdentityCollection
38  "FilePath": null, //alternate to passing 'Data' (serverSide Path)
39  "FolderId": null,
40  "FolderTypeId": null,
41  "MimeType": null, //required
42  "PageDataList": [], // PageDataCollection
43  "PageImages": [], // PageImageDataCollection
44  "ReturnAllFields": true,
45  "RuntimeFields": [] // RuntimeFieldcollection
46  };
47  return rtd
48  };
49 
50  var VariableIdentity = function () {
51  var vId = {
52  "Id": null, //required
53  "Name": null
54  };
55  return vId;
56  }
57 
58  var jobJSON = new CreateJobWithDocumentsAndProgress2Struct();
59  jobJSON.sessionId = "3F05A05532EA469D8F9FC150A61D5CBB";
60  jobJSON.processIdentity.Id = "DB65BE80231045779AED6D802C2CAD6C";
61  jobJSON.processIdentity.Name = "Bank - Standard Capture";
62 
63  var rVar = new VariableIdentity();
64  rVar.Id = "LOT_NUMERISATION";
65  jobJSON.variablesToReturn.push(rVar);
66 
67  var rtd1 = new RuntimeDocument();
68 
69  rtd1.Base64Data = "<<base64 data would go here>>";
70  rtd1.MimeType = "image/tiff";
71  rtd1.ReturnAllFields = true;
72  jobJSON.jobWithDocsInitialization.RuntimeDocumentCollection.push(rtd1);
73 
74  var rtd2 = new RuntimeDocument();
75  rtd2.Base64Data = "<<base64 data would go here>>";
76  rtd2.MimeType = "image/tiff";
77  rtd2.ReturnAllFields = true;
78  jobJSON.jobWithDocsInitialization.RuntimeDocumentCollection.push(rtd2);
79 
80  $("#Request").html("<BR/><B>Request:</B><BR/>" + JSON.stringify(jobJSON));
81 
82  // Call CreateJobWithDocumentsAndProgress2 method
83  $.ajax({
84  type: "POST",
85  async: "false",
86  url: "http://localhost/TotalAgility/Services/Sdk/JobService.svc/json/CreateJobWithDocumentsAndProgress2",
87  data: JSON.stringify(jobJSON),
88  contentType: "application/json; charset=utf-8",
89  crossDomain: true,
90  dataType: "json",
91  success: function (result) {
92  $("#Result").html("<BR/><B>Response: </B><BR/>" + JSON.stringify(result.d));
93  },
94  error: function (jqXHR, textStatus, errorThrown) {
95  alert("***Error***\n");
96  }
97  });
98 
99  </script>
100 </body>
101 </html>

Calling ActivityService


Method: GetWorkqueue2()
1 <html>
2 <body>
3  <header>
4  <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
5  </header>
6  <div id="Request"></div>
7  <div id="Result"></div>
8  <script>
9 
10  var GetWorkQueueStruct = function () {
11  var struct = {
12  "jobActivityFilter": {
13  "NodeId": 0,
14  "LoanResource": {
15  "Id": null,
16  "Name": null,
17  "ResourceType": 0
18  },
19  "EndDueDateTime": null,
20  "StatusFilter": 0,
21  "JobIdsFilter": null,
22  "MaxActivitiesCount": 100,
23  "StartDueDateTime": null,
24  "StartPendingTime": null,
25  "ActivityTypeFilters": 0,
26  "WorkQueueDefinition": {
27  "Id": "",
28  "Name": ""
29  },
30 
31  "MetaDataFilter": {
32  "Filter": "",
33  "FilterOperator": 0
34  },
35  "ReturnJobIds": false,
36  "UsePrioritySetting": 0,
37  "Priority": -1,
38  "ActivityName":"",
39  "Resource": {
40  "Id": null,
41  "Name": null,
42  "ResourceType": 0
43  },
44 
45  "UseCombinedWorkQueue": false,
46  "UseJobSlaStatus": false,
47  "JobSlaStatus": 0,
48  "JobState": null,
49  "PageDirection":0,
50  "UseActivitySlaStatus": false,
51  "ActivitySlaStatus": 0,
52  "CaseActivitiesOnly": false,
53  "Process": {
54  "Id": "",
55  "Name": "",
56  "Version": 0
57  },
58  "Case": {
59  "CaseId": "",
60  "CaseReference": "",
61  "Name": null
62  },
63 
64  "Category": {
65  "Id": null,
66  "Name": null,
67  },
68  "ScoreFilter": {
69  "Filter": "",
70  "ScoreOperator": 0
71  },
72  "PriorityType": 0,
73  "DueDateType": 0,
74  },
75  "sessionId": ""
76  };
77  return struct;
78  };
79 
80 
81  var getWorkQueueJSON = new GetWorkQueueStruct();
82  getWorkQueueJSON.sessionId = "FA4CAE506A5F49FF90C832BCA311C439";
83  getWorkQueueJSON.jobActivityFilter.MaxActivitiesCount = 100;
84  getWorkQueueJSON.jobActivityFilter.UseCombinedWorkQueue = true;
85 
86  $("#Request").html("<BR/><B>Request:</B><BR/>" + JSON.stringify(getWorkQueueJSON));
87 
88  // Call GetWorkQueue2 method
89  $.ajax({
90  type: "POST",
91  async: "false",
92  url: "http://localhost/TotalAgility/Services/Sdk/ActivityService.svc/json/GetWorkQueue2",
93  data: JSON.stringify(getWorkQueueJSON),
94  contentType: "application/json; charset=utf-8",
95  crossDomain: true,
96  dataType: "json",
97  success: function (result) {
98  $("#Result").html("<BR/><B>Response: </B><BR/>" + JSON.stringify(result.d));
99  },
100  error: function (jqXHR, textStatus, errorThrown) {
101  alert("***Error***\n");
102  }
103  });
104 
105  </script>
106 </body>
107 </html>

Method: TakeActivity()
1 <html>
2 <body>
3  <header>
4  <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
5  </header>
6  <div id="Request"></div>
7  <div id="Result"></div>
8  <script>
9 
10  var TakeActivityStruct = function () {
11  var struct = {
12  "sessionId": "",
13  "jobActivityIdentity":
14  {
15  "NodeId": 0,
16  "EmbeddedProcessCount": 0,
17  "JobId": "",
18  "SubNodeId": 0,
19  "Automatic": false,
20  "ActivityName": null
21  }
22  };
23  return struct;
24  };
25 
26 
27  var takeActivityJSON = new TakeActivityStruct();
28  takeActivityJSON.sessionId = "FA4CAE506A5F49FF90C832BCA311C439";
29  takeActivityJSON.jobActivityIdentity.NodeId = 1;
30  takeActivityJSON.jobActivityIdentity.EmbeddedProcessCount = 0;
31  takeActivityJSON.jobActivityIdentity.JobId = "FD871D79AA544328B7EB99A8E42727B9";
32 
33  $("#Request").html("<BR/><B>Request:</B><BR/>" + JSON.stringify(takeActivityJSON));
34 
35  // Call TakeActivity method
36  $.ajax({
37  type: "POST",
38  async: "false",
39  url: "http://localhost/TotalAgility/Services/Sdk/ActivityService.svc/json/TakeActivity",
40  data: JSON.stringify(takeActivityJSON),
41  contentType: "application/json; charset=utf-8",
42  crossDomain: true,
43  dataType: "json",
44  success: function (result) {
45  $("#Result").html("<BR/><B>Response: </B><BR/>" + JSON.stringify(result.d));
46  },
47  error: function (jqXHR, textStatus, errorThrown) {
48  alert("***Error***\n");
49  }
50  });
51 
52  </script>
53 </body>
54 </html>

Method: CompleteActivity()
1 <html>
2 <body>
3  <header>
4  <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
5  </header>
6  <div id="Request"></div>
7  <div id="Result"></div>
8  <script>
9 
10  var CompleteActivityStruct = function () {
11  var struct = {
12  "jobActivityIdentity":
13  {
14  "NodeId": 0,
15  "EmbeddedProcessCount": 0,
16  "JobId": "",
17  "SubNodeId": 0,
18  "Automatic": false,
19  "ActivityName": null
20  },
21  "jobActivityOutput": {
22  "OutputVariables": [],
23  "SetTime": null,
24  "Cost": null
25  }
26  };
27  return struct;
28  };
29 
30 
31  var completeActivityJSON = new CompleteActivityStruct();
32  completeActivityJSON.sessionId = "FA4CAE506A5F49FF90C832BCA311C439";
33  completeActivityJSON.jobActivityIdentity.NodeId = 1;
34  completeActivityJSON.jobActivityIdentity.EmbeddedProcessCount = 0;
35  completeActivityJSON.jobActivityIdentity.JobId = "FD871D79AA544328B7EB99A8E42727B9";
36 
37  $("#Request").html("<BR/><B>Request:</B><BR/>" + JSON.stringify(completeActivityJSON));
38 
39  // Call TakeActivity method
40  $.ajax({
41  type: "POST",
42  async: "false",
43  url: "http://localhost/TotalAgility/Services/Sdk/ActivityService.svc/json/CompleteActivity",
44  data: JSON.stringify(completeActivityJSON),
45  contentType: "application/json; charset=utf-8",
46  crossDomain: true,
47  dataType: "json",
48  success: function (result) {
49  $("#Result").html("<BR/><B>Response: </B><BR/>" + JSON.stringify(result.d));
50  },
51  error: function (jqXHR, textStatus, errorThrown) {
52  alert("***Error***\n");
53  }
54  });
55 
56  </script>
57 </body>
58 </html>