locked
CRM 2011 - Jscript using REST Calls RRS feed

  • Question

  • Hi,

    I'm currently working on a custom entity called appeal (new_appeal) and I have a lookup to a custom entity called Assessment (new_assessment). I'm wanting to create some code which from the appeal entity, I need to retrieve the effective date (new_effectivedate) from the assessment entity and pass this on into a single line of text field called Message (new_message), this will be onload of a appeal record. Can anyone point me in the right direction/supply me with some code which will assist, its quite a urgent requirement.

    Many Thanks

    Paul

    Monday, March 3, 2014 7:59 PM

Answers

  • Hi Paul,

    Download the SDK for Dynamics CRM 2011 from here : http://www.microsoft.com/en-us/download/details.aspx?id=24004. You should find a file named "SDK.REST.js" at "SDK\SampleCode\JS\RESTEndpoint\JavaScriptRESTDataOperations\JavaScriptRESTDataOperations\Scripts"

    Use that library Microsoft has provided to make the REST calls. The example of calling the function is present in the JavaScript file in that folder itself. Go through it and you should be able to get the idea of making REST calls using JavaScript. The function you need to use is "retrieveRecord".

    It should be something as follows:

    function retrieveAssesment(AssessmentId) 
     SDK.REST.retrieveRecord(
         AssessmentId,
         "new_assessment",
         "$select=new_effectivedate",null,
         function (assessment) {
          //populate field in appeal
         },
         errorHandler
       );
    }

    Inside the success callback function use this to populate the new_message field.

    Xrm.Page.getAttribute("new_message”).setValue(your_value)


    <a href="http://mscrmhacks.com/admin-quikview-solution-crm-2013/">Admin QuikView Solution for CRM 2013</a> | <a href="http://mscrmhacks.com">My Blog</a>

    • Proposed as answer by Linn Zaw Win Tuesday, March 4, 2014 2:33 AM
    • Marked as answer by samrr1875 Tuesday, March 4, 2014 8:53 AM
    Monday, March 3, 2014 11:01 PM