Datapolis Process System SDK

Search:

Contents
:
IndexBookmarkPrint
Home > Datapolis Column Protector Service > Consuming Service

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"></script>

 

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) {
}
 
function onErrorCallback(xmlRequest) {
}


3. Fill script with custom data:

  • Replace [SharePoint Site Url] with your Site Url
  • Replace [Method Name] with Web Method name you want to call
  • Replace [Parameters] with parameters requred by Web Method you choose. For example: data: "{ listId: 'EE44F204-A292-47D2-838E-BA49A56936C2', contentTypeId: '0x01' }"
  • Replace [Data Type To Return] with: "xml" if you want to receive parsed javascript xml which can be iterated and traversed or "text" when you want to obtain xml in form of string

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();
var contentTypeString = $("#contentTypeInput").val();
 
var parameters = JSON.stringify({ listId: listGuid, contentTypeId: contentTypeString });

 

 4. Complete script should look similar to this pattern

 

var listGuid = $("#listGuidInput").val();
var contentTypeString = $("#contentTypeInput").val();
 
var parameters = JSON.stringify({ listId: listGuid, contentTypeId: contentTypeString });
 
$.ajax({
type: "POST",
data: parameters,
contentType: "application/json; charset=utf-8",
dataType: "text",
success: onSuccess,
error: onError
});
 
function onSuccess(data, status) {
alert(data);
}
 
function onError(xmlRequest) {
alert(xmlRequest.responseText);
}

 

Returned value format


<Result>
  <Status>Success</Status>
  <HiddenFields>
    <FieldRef Name="HiddenFieldName" />
    <FieldRef Name="AnotherHiddenFieldName" />
  </HiddenFields>
  <ReadOnlyFields>
    <FieldRef Name="ReadOnlyFieldName" />
    <FieldRef Name="AnotherReadOnlyFieldName" />
  </ReadOnlyFields>
</Result>

 

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).