Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Create custom fields for leads through the API

Posted on by 5

Hi all,

I'm working on an integration for Dynamics 365 for Sales with our system, and I'm trying to figure out a couple of things.

One thing that I would like to be able to do is to add a custom field to a lead where I could save our systems' ID so that we can cross match it later as that lead is processed. I've found a lot of documentation about custom leads, but all of them are how to create them through the UI, I wasn't able to find any information about how to do it through the Web API.

What would be the correct way to create a custom field on an entity (Lead) through the API? Can I use the access token that I have with CRM scope, or do I need to use some other Apps?

Thanks!

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Create custom fields for leads through the API

    Hello,

    It is possible to create custom columns using the API. Check this post - docs.microsoft.com/.../create-update-entity-definitions-using-web-api

  • driftrock Profile Picture
    driftrock 5 on at
    RE: Create custom fields for leads through the API

    Is there a way to create the field in the Lead Table through the API instead of going through the interface as you describe? I'm working on a multitenant App, and I would like to be able to create a new "external_id" field for a lead without the interaction from the user (after they have done the login and I have a valid access token on their behalf)

  • Wahaj Rashid Profile Picture
    Wahaj Rashid 11,319 on at
    RE: Create custom fields for leads through the API

    Hi,

    Thank you for your query.

    As far as I understood, you need to add a custom field to store the ID of an external system.

    You do not need to create the field via API, you need to update this field using API.

    Here is the high-level solution:

    • Create a field in the Lead Tabel (entity):
      • Go to Advanced Settings -> Customizations -> Customize this System (Or create a new solution).
      • Expand Entities -> Lead -> Fields.
      • Create a new field of type Text (string), for example, new_externalid.
      • Save and Publish the entity.
      • You can also add this field on the Lead form (optional).
    • Use Web API to update this field while creating or updating the record:

                Create a table row using the Web API (Microsoft Dataverse) - Power Apps | Microsoft Docs

    You can set the new field in the Payload:

    POST [Organization URI]/api/data/v9.0/leads HTTP/1.1
    Content-Type: application/json; charset=utf-8
    OData-MaxVersion: 4.0
    OData-Version: 4.0
    Accept: application/json
    {
        "subject": "New Lead",
        "fullname": John Doe,
        "new_externalid":"LEAD-XYZ-00910"
    }

    You can also update using web-api:

    Update and delete table rows using the Web API (Microsoft Dataverse) - Power Apps | Microsoft Docs

    Create a custom field:

    Create and edit fields with Dynamics 365 Customer Engagement (on-premises) | Microsoft Docs

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans