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

Community site session details

Session Id :
Dynamics 365 general forum

Retrieve Account Id from a Workflow

(0) ShareShare
ReportReport
Posted on by 2

Hi,

I have created a workflow where I want to retrieve the newly created id from the account entity.

I was trying to avoid doing this with a plugin and instead wanted to create a really simply workflow that takes the id of record that was just created or updated and adds a record to another entity.

So... account is created, the id is captured and sent be second entity.

However, I don't seem to be able to find the "id" field anywhere in the list... I have tried a few of the other options and have found none that provide the value I want.

Is this not possible with workflows?

Thanks - Greg

Categories:
I have the same question (0)
  • Greggomatic Profile Picture
    2 on at
    RE: Retrieve Account Id from a Workflow

    Thanks Guido - this is where I was heading - thanks for the confirmation.

  • Verified answer
    Guido Preite Profile Picture
    54,084 Moderator on at
    RE: Retrieve Account Id from a Workflow

    you need a custom workflow activity for that, but it's very simple

    here a tutorial for starting msdn.microsoft.com/.../gg334455.aspx

    you will need an inputparameter as entityreference

    an output parameter as string

    and inside the execute method you just need to read the id property of the entityreference and set to the output parameter

    something like

    public sealed class GetRecordId : CodeActivity
       {
           [Required]
           [Input("Account")]
           [ReferenceTarget("account")]
           public InArgument<EntityReference> Account { get; set; }
    
           [Output("Account Id")]
           public OutArgument<string> AccountId { get; set; }
           protected override void Execute(CodeActivityContext executionContext)
           {
               EntityReference accountRef = Account.Get<EntityReference>(executionContext);
               AccountId.Set(executionContext, accountRef.Id.ToString());
           }
       }


  • Greggomatic Profile Picture
    2 on at
    RE: Retrieve Account Id from a Workflow

    Hi Guido - yes, I just want the Id as string (guid format).

    Is this possible or do I need to go down the path of creating a custom workflow activity.

  • Suggested answer
    Guido Preite Profile Picture
    54,084 Moderator on at
    RE: Retrieve Account Id from a Workflow

    Hi Greg,

    I suppose you will need the Id as a string? because if you need to set as a lookup you can assign it in the process designer to a field that accept the contact lookup

    if you need the id as string an alternative you can create a custom workflow activity

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Dynamics 365 general

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans