Datapolis Process System SDK
Consuming Service
Datapolis Column Protector Service is typical SOAP service that can be consumed with several different methods, for example by adding Service Reference in Visual Studio project. Additionally, this file contains instruction how to call this Service by making an AJAX call directly from JavaScript code.
Consuming Datapolis Column Protector Service from javascript
To consume Datapolis Column Protector Service from JavaScript, follow below instructions, for example by making jQuery AJAX call.
1. Add jQuery header to the file from which you want to call Service. You can add jQuery to your project and reference it's path, or reference one of global urls for jQuery, for example
<
script
src
=
"//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"
xmlns
"http://ddue.schemas.microsoft.com/authoring/2003/5"
></
>
2. Add script that will call Datapolis Column Protector Service to page, from which script will be executed.
$.ajax({
type:
"POST"
,
url:
"http://[SharePoint Site Url]/_layouts/15/Datapolis.WorkBox.SharePointColumnProtector/SCPService.asmx/[Method Name]"
data:
"{ [Parameters] }"
contentType:
"application/json; charset=utf-8"
dataType: [Data Type To Return],
success: onSuccessCallback,
error: onErrorCallback
});
function
onSuccessCallback(data, status) {
}
onErrorCallback(xmlRequest) {
3. Fill script with custom data:
onSuccessCallback and onErrorCallback are callback methods which are called by Datapolis Column Protector Service. You can freely change their names.
Success callback returns Datapolis Column Protector data in "data" parameter and status of Datapolis Column Protector Service execution in "status" parameter. Error callback returns XML with error detail in "xmlRequest" attribute. Remember that this callback contains description of errors related to calling Web Service, not to Datapolis Column Protector settings.
You can use JSON.stringify method to create parameters string in JSON format. This method is useful when you are obtaining parameter values from controls.
var
listGuid = $(
"#listGuidInput"
).val();
contentTypeString = $(
"#contentTypeInput"
parameters = JSON.stringify({ listId: listGuid, contentTypeId: contentTypeString });
4. Complete script should look similar to this pattern
"http://SharePointSite/_layouts/15/Datapolis.WorkBox.SharePointColumnProtector/SCPService.asmx/GetContentTypeHiddenFields"
data: parameters,
dataType:
"text"
success: onSuccess,
error: onError
onSuccess(data, status) {
alert(data);
onError(xmlRequest) {
alert(xmlRequest.responseText);
Returned value format
Result
Status
>Success</
HiddenFields
FieldRef
Name
"HiddenFieldName"
/>
"AnotherHiddenFieldName"
</
ReadOnlyFields
"ReadOnlyFieldName"
"AnotherReadOnlyFieldName"
Datapolis Column Protector Service methods:
Method name
Description
GetContentTypeHiddenFields(Guid listId, string contentTypeId)
Returns information about hidden fields for given content type.
GetContentTypeReadOnlyFields(Guid listId, string contentTypeId)
Returns information about read only fields for given content type.
GetContentTypeAllDisallowedFields(Guid listId, string contentTypeId)
Returns information about readonly and hidden fields for given content type.
GetListItemHiddenFields(Guid listId, int itemId)
Returns information about hidden fields for given list item (based on it's content type).
GetListItemReadOnlyFields(Guid listId, int itemId)
Returns information about readonly fields for given list item (based on it's content type).
GetListItemAllDisallowedFields(Guid listId, int itemId)
Returns information about readonly and hidden fields for given list item (based on it's content type).