Hi Team,
i need help with below java scripts, it is for one fields ““FieldIds”:[1234]”, when i am adding more fields not working, where “ContentIds” :[55555]}" is constant.
<br>
<span>Run AJAX Reference Code:</span>
<button id = "ajaxStartButton" type="button" onclick = "AjaxStart();">Start</button>
<br>
<br>
<textarea id="ajaxLogTextArea" rows="15" cols="100"></textarea>
<br>
<script>
function AjaxStart()
AjaxGetAllGroups()
}
async function AjaxGetAllGroups() {
$('#ajaxLogTextArea").val($('#ajaxLogTextArea").val() + "Acquiring Contentid..." + "\r\n");
var requestSettings = {
'url' : 'https://' + window.location.hostname + '/XXX' + '/Platformapi/core/content/fieldcontent',
'method': 'POST',
'headers': {
'Accept': 'appliaction/jason,text/html,appliaction/xhtml+xml,appliaction/xml;q =0.9, */*;q=0.8',
'Contect-Type': 'application/json',
'x-csrf-token': (window.sessionStroage) ? window.sessionStorage.getItem("x-csrf-token") : parent.parent.Archerapp.globals['xCsrfToken']
},
'data': '{"FieldIds":[1234], "ContentIds" :[55555]}'
// 'data': '{"FieldIds":[1234],[3456],[3333], "ContentIds" :[55555]}' ---add more fields for same content id
};
$.ajax(requestSettings).done(resposne => {
console.log(resposne);
var contentId = resposne[0].RequestedObject.FieldContents["1234"].Value[0].ContentId;
// var contentId1 = resposne[0].RequestedObject.FieldContents["1234"].Value[0].ContentId;
// var contentId = resposne[0].RequestedObject.FieldContents["1234"].Value[0].ContentId;
GetNameOnContactRecord(contentId)
sync function GetNameOnContactRecord(ContentId) {
$("#ajaxLogTextArea").val($"#ajaxLogTextArea").val() + "Acquiring name on Contact record " +contectId + "..." + "\r\n");
var requestSettings = {
'url' : 'https://' + window.location.hostname + '/XXX' + '/platformapi/core/content/fieldcontect',
'method' : 'POST',
'async' : true,
'headers': {
'Accept': 'appliaction/jason,text/html,appliaction/xhtml+xml,appliaction/xml;q =0.9, */*;q=0.8',
'Contect-Type': 'application/json',
'x-csrf-token': (window.sessionStroage) ? window.sessionStorage.getItem("x-csrf-token") : parent.parent.Archerapp.globals['xCsrfToken']
},
'data': '{"FieldIds":[567], "ContentIds" :[' +contentId.toString() + ']}'
};
$.ajax(requestSettings).done(resposne => {
console.log(resposne);
var name = resposne[0].RequestedObject.FieldContents["567"].Value;
$("#ajaxLogTextArea").val($("#ajaxLogTextArea").val() + "Name on Contact record = "name + "\r\n");
$("#ajaxLogTextArea").val($("#ajaxLogTextAera").val() + "Name on Contact record = " + name + "\r\n");
});