JScript: Retrieving and Updating Records using REST.js sample CRM 2011

Microsoft Dynamics CRM is a Customer Relationship Management software package developed by Microsoft
Post Reply
User avatar
gellee
Posts: 46
Joined: Fri Jan 20, 2012 3:04 pm

JScript: Retrieving and Updating Records using REST.js sample CRM 2011

Post by gellee »

Code: Select all

function retrieveRecord() {
    var parentAccount = Xrm.Page.getAttribute("parentcustomerid");
    var parentAccountId = parentAccount.getValue()[0].id;

    if (parentAccount.getValue()[0].entityType == "account") {
        RetrieveRecord(parentAccountId, "Account")
    }
    else {
        RetrieveRecord(parentAccountId, "Contact")
    }


}

function retrieveRecord() {

	var gridControl = document.getElementById('List_Of_all_Items2').control
	var ids = gridControl.get_allRecordIds();

	for (i = 0; i < ids.length; i++) 
	{

	SDK.REST.retrieveRecord
	(
		parentAccountId
		, entityType
		, null
		, null
		, function (Account) {
		    updateAllRecords(Account);
		}
		, errorHandler
	);

	}


}



function updateAllRecords(Account) {
    Xrm.Page.getAttribute("address1_city").setValue(Account.Address1_City);    
}

function errorHandler() {
    //do nothing
}
xaeresis
Posts: 196117
Joined: Wed Oct 04, 2023 2:39 pm

Re: JScript: Retrieving and Updating Records using REST.js sample CRM 2011

Post by xaeresis »

xaeresis
Posts: 196117
Joined: Wed Oct 04, 2023 2:39 pm

Re: JScript: Retrieving and Updating Records using REST.js sample CRM 2011

Post by xaeresis »

Post Reply