web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to Insert/Create new record in custom entity using JavaScript

(0) ShareShare
ReportReport
Posted on by

Is it possible to add new record in custom entity based on Contact create in MSCRM.

Don't want to use Plugin/Workflow.

Please suggest me.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Ashish,

    You can use sdk.rest library to create a record from java script.

    var objectValues= new Object();

    objectValues.<fieldName>=value;

     SDK.REST.createRecord(objectValues, "<EntityName>", callBackFuction, function (error) { alert(error.message); });

  • necsa Profile Picture
    3,455 on at

    Hi Ashish Manatkar,

    please get information of following links;

     https://migsbeja.wordpress.com/2015/05/14/change-lookup-text-originating-lead-field/


     http://snipplr.com/view/70031/

  • Ashish D Manatkar Profile Picture
    on at

    These links tells that how to get and set value. I would like to create new record from the javascript in the custom entity based on create operation of contact record

  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at

    You can write script on contact save and call your script to create custom entity record. you can look for OData designer to write your query, Or Can use SDK library for the same as suggested.

    Thanks

  • necsa Profile Picture
    3,455 on at

    Hi Ashish Manatkar,

    please take following information to create a new record over lookup field.

    https://blogs.msdn.microsoft.com/crm/2013/12/03/whats-new-in-the-lookup-control-with-microsoft-dynamics-crm-2013/

  • Ashish D Manatkar Profile Picture
    on at

    Necdet, I would like to create a new record using javascript only on the creation of new contact records

  • Pranesh M Juwale Profile Picture
    1,196 on at

    Hi Ashish,

    You can create new record of custom entity using OData & Jquery.

    As per your requirement, you can set the script "onsave" of contact entity.

    Check the following link:

    lakshmanindian.wordpress.com/.../create-record-using-jscript-in-microsoft-dynamics-crm-2011

    andreaswijayablog.blogspot.in/.../crm-2011-jquery-odata-rest-endpoints.html

    Odata query designer download link:

    dynamicsxrmtools.codeplex.com

    Hope this help out.

  • Suggested answer
    migsbeja Profile Picture
    655 on at

    Hi Ashish,

    Maybe you can do it like this:

    OnSave of the Contact you have to do this code (you need to change the entity name and field to match what you desire).

    This uses the XrmServiceToolkit.js to help with the create/update (and more) functions.

    //Create Entity
    var entity = new XrmServiceToolkit.Soap.BusinessEntity("EntityName");
    //String
    entity.attributes["fieldName"] = Xrm.Page.getAttribute("fieldName").getValue();
     
    //Lookup
    entity.attributes['fieldName'] = { id : Xrm.Page.getAttribute('fieldName').getValue()[0].id, logicalName : Xrm.Page.getAttribute('fieldName').getValue()[0].entityType, type : 'EntityReference' };
     
    //Bool
    entity.attributes["fieldName"] = Xrm.Page.getAttribute("fieldName").getValue();
     
    //OptionSetValue
    entity.attributes["fieldName"] = { value: Xrm.Page.getAttribute("fieldName").getValue(), type: "OptionSetValue" };
     
    //Currency
    entity.attributes["fieldName"] = { Value: Xrm.Page.data.entity.attributes.get("fieldName").getValue() };
     
    //Decimal
    entity.attributes["fieldName"] = { Value: parseFloat(eval(Xrm.Page.data.entity.attributes.get("fieldName").getValue())) };
     
    var quoteId;
    quoteId = XrmServiceToolkit.Soap.Create(entity);

    You can find this and how to update entity in: https://migsbeja.wordpress.com/2015/02/07/createupdate-entity-using-xrmservicetoolkit-soap/

     

    Best Regards,

    Miguel

  • Community Member Profile Picture
    on at

    I have client name  

    A , B , C , D

    A  - installed my solution

    B  - Installed my solution

    c  - installed my solution

    D  - Installed my solution

    then i have given webresource page . (just contact info page )

    All client are filled the form .

    When A (client )  login into their CRM and open my solution which they installed  .whatever contact info A filled which i need to pre populate .

    When B (client )  login into their CRM and open my solution which they installed  .whatever contact info B filled which i need to pre populate .

    When A=C (client )  login into their CRM and open my solution which they installed  .whatever contact info C filled which i need to pre populate .

    Question : -

    if i know any unique id of client only i can  query my db and per populate the field . How can i find the unique id of the client ?

    since my solution is third party to them . they will install the solution only . what logic should i implement to get unique id of that client ?

    Same logic i should apply into getting data also to entity  which question i asked previously .

    Thanks

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans