Custom code/Java Script/AJAX

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");
});
sync function GetNameOnContactRecord(ContentId) {

Is this a typo? Did you mean “async”?

Yes, it is typo
async function GetNameOnContactRecord(ContentId) {

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.