Field: Update Field of Opportunity Product Associated with Opportunity Entity 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

Field: Update Field of Opportunity Product Associated with Opportunity Entity CRM 2011

Post by gellee »

In Microsoft Dynamics CRM, we have to add json2.js and sdk.rest.js in CRM web resource. These web resources is located in Microsoft Dynamic CRM 2011 sdk. To download the sdk, here is the url: http://www.microsoft.com/download/en/de ... x?id=24004

The two web resource (json2.js and sdk.rest.js) are located at: sdk\samplecode\js\restendpoint\javascriptrestdataoperations\javascriptrestdataoperations

Code: Select all

function updateIsPriceOverridden() { //update field of opportunity product-associated with opportunity entity
    var id = Xrm.Page.data.entity.getId();

    SDK.REST.retrieveRecord(id, "Opportunity", null, "product_opportunities", updateOpportunityProduct, errorHandler);
}


function updateOpportunityProduct(id_pass) {

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


    var changes = {};
    changes.IsPriceOverridden = true;

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

        SDK.REST.updateRecord(id_pass.product_opportunities.results[i].OpportunityProductId, changes,
"OpportunityProduct", updateOpportunityProductCompleted, errorHandler);
    }

}



function updateOpportunityProductCompleted() {
    //do nothing
}

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

Re: Field: Update Field of Opportunity Product Associated with Opportunity Entity CRM 2011

Post by xaeresis »

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

Re: Field: Update Field of Opportunity Product Associated with Opportunity Entity CRM 2011

Post by xaeresis »

Post Reply