Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Need Primary key in a custom work flow

Posted on by 12,070 Super User 2024 Season 1

Hi all

I create an entity in crm 2011 as shown below

Pk.jpg

This is my PK in crm but in the database this is not the PK. My PK is mailchimpid as shown below

Pk1.jpg

How can I get this pk in my custom workflow? I am trying to get this but it is giving me this error

Pk2.jpg

Thank You

*This post is locked for comments

  • Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Super User 2024 Season 1 on at
    RE: Need Primary key in a custom work flow

    Hi Aiden Kaskela (MVP)

    Thank You very much

  • Verified answer
    Aiden Kaskela Profile Picture
    Aiden Kaskela 19,692 on at
    RE: Need Primary key in a custom work flow

    Hi Abdul,

    I'm not quite sure I understand what you're asking. In the plugin, you want to query for Mail Chimp records and get the primary key of those records? You would do it like this:

    QueryExpression query = new QueryExpression
    {
     EntityName = "aw_mailchimp",
     ColumnSet = new ColumnSet("aw_mailchimpid")
    };
    EntityCollection results = service.RetrieveMultiple(query);
    if (results.Entities.Count > 0)
    {
     // If there are records
     Guid thePrimaryKey = results.Entities[0].Id;
    }

    Thanks,

      Aiden

  • Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Super User 2024 Season 1 on at
    RE: Need Primary key in a custom work flow

    Hi Aiden Kaskela (MVP)

    I am not able to see my primary key in crm which is generated by sql itself.

    When I make advanced find view. It is look like as shown below:

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">

     <entity name="aw_mailchimp">

       <attribute name="aw_mailchimpid" />

       <attribute name="aw_name" />

       <attribute name="createdon" />

       <order attribute="axp_name" descending="false" />

       <filter type="and">

         <condition attribute="aw_mailchimpid" operator="eq" uiname="AXPulse" uitype="aw_mailchimp" value="{6A1C0CE4-8ACF-E611-999E-005056C00008}" />

       </filter>

     </entity>

    </fetch>

    I want to get aw_mailchimpid in my custom workflow. I know all the things that you told me and I am able to get all remaining fields of this table. How can I get aw_mailchimpid in my custom work flow?

    Thank You

  • Suggested answer
    Aiden Kaskela Profile Picture
    Aiden Kaskela 19,692 on at
    RE: Need Primary key in a custom work flow

    Abdul,

    I can't tell what's wrong because you hid all the relevant details. Your entity name needs to be the schema name of the entity, and it'll have a prefix. Something like "aw_mycustomentity". Same thing with the ID, since it's a custom field it has some prefix: "aw_mycustomentityid". Please post updated screenshots if this doesn't help.

    I'd appreciate if you'd mark this as Answering your question.

    Thanks,

     Aiden

  • Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Super User 2024 Season 1 on at
    RE: Need Primary key in a custom work flow

    Hi Aiden

    I am writing this code.

    QueryExpression query = new QueryExpression

               {

                   EntityName = mailchimp

                   ColumnSet = new ColumnSet(maillchimpid)

               };

    EntityCollection results = service.RetrieveMultiple(query);

    This code giving above error.

    Thank You

  • Suggested answer
    Aiden Kaskela Profile Picture
    Aiden Kaskela 19,692 on at
    RE: Need Primary key in a custom work flow

    Hi Abdul,

    It's tough to tell what's going on in your screenshots because they're trimmed down so much. Do you have a custom workflow plugin that's trying to do something with the ID of the record that's giving the error?

    If you want the ID of the workflow record to work with in you workflow, you can install my free add-on called Workflow Elements (https://kaskela.wordpress.com). There's a workflow activity to call "Workflow - Get Metadata" which has an output parameter called "Workflow Record – Record ID", which is the ID of your record.

    Hope this helps! I'd appreciate if you'd mark this as Answering your question.

    Thanks,

     Aiden

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