Advertisements
Home > CRM 2011, JScript > Create record using OData and JQuery in CRM 2011
  1. March 20, 2012 at 3:25 PM

    Hi Rajeev Ji,

    Thanks for this post. I tried your code and but I don’t know way it was not working when I added “Json2.js” & “jquery1.4.1.min.js” helper script files. And after added “jquery.1.4.1.js” your code worked fine.
    Why your code work with only two support files and I need three. Please reply me if you have any idea.

    Thanks in advance.

  2. March 28, 2012 at 6:59 PM

    Hi,
    “Jquery.1.4.1.min.js” is minified version.
    I am able to create records with minified version.

    Please double check the file you used.
    OR
    Use the “jquery1.4.1.min.js” file which comes with CRM 2011 SDK (Refer path below)
    \sdk\samplecode\js\restendpoint\jqueryrestdataoperations\jqueryrestdataoperations\scripts

  3. Susan
    June 30, 2012 at 5:40 PM

    Hi Rajeev,

    I am facing a strange problem while I try to create an opportunity entity record using the same javascript.

    I am using the above code and also the JQueryRESTDataOperations sample from SDK/MSDN which sets the Revenue field account , the only difference is that I set he value for new_totalamount field in opportunity record.

    I am trying to set the custom attrbute Total Amount value equal to 100 when I get this error.
    the code I use is
    opp.new_TotalAmount = { Value: “100.00” }; //Set Total Amount

    The error is as : “Error processing request stream. The type name ‘Microsoft.Crm.Sdk.Data.Services.OptionSetValue’ is not valid for the given URI it represents. The expected type must be ‘Microsoft.Crm.Sdk.Data.Services.Money’ or one of its derived types.”

    This is very strange as I am able to create the entity record if I comment this line. Also I have double check with the attribute name and type, it is a currency type attribute.

    Please can you help me out.

    Thanks

    • June 30, 2012 at 9:25 PM

      Hi Susan,

      I am able to create record with currency field with the same syntax provided in SDK

      myProd.new_Revenue = { Value: “100.00” };

      I wonder why it’s not working in your case.

      As workaround, try creating object and set the currency value as below
      var objRevenue = new Object;
      var amount = 100;
      myProd.new_Revenue = { Value: eval(amount).toString() };

      If it does not work, delete and recreate the field or send me the solution with your entity customization to dig deeper.

      Thanks,
      Rajeev

  4. Saurin
    July 26, 2012 at 3:54 AM

    Hi Rajeev,
    I am getting an error while setting a decimal value, the code works for money attribute but even after trying numerous formatting and conversions for decimal, it doesn’t work.

    account.Quantity = { Value: eval(1) };
    or
    account.Quantity = 1;
    or
    account.Quantity = { Value: “1” };

    • August 23, 2012 at 2:12 PM

      Hi Saurin,
      Try this

      // Set a Decimal field (Here ‘new_DecimalField’ is my custom Account field)
      account.new_DecimalField = 200.00.toString();

      Let me know if you still face issue

  5. ihsacrm
    August 21, 2012 at 11:04 PM

    Error on the creation of record; Error
    How can I find out what the actual error isÉ
    Thanks!

  6. ihsacrm
    August 21, 2012 at 11:11 PM

    …sory, there was an error posting previous message!

    Error on the creation of record; Error – [object Error]
    Any idea?

  7. August 22, 2012 at 4:34 AM

    I am getting the message:
    Error on the creation of record; Error – [object Error]

    Please advice !

    • August 23, 2012 at 9:05 AM

      Hi,
      Note that all the properties are Case sensitive
      var primaryContact = new Object();
      primaryContact.ContactId = “123”;
      Here “ContactId” should be of same case. Use ODataQueryDesigner to get the properties.

  8. Seema
    July 9, 2014 at 6:08 PM

    Hi Rajeev,
    Thank you for the post.I am new to the CRM.I use the trial version CRM 2013. When i tried this, the error callback function is called.I am unable to find where the fault is…
    Can you help me in this!!

  1. January 21, 2013 at 1:18 PM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: