Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Process Mining
Answered

Get record id from CDS

(0) ShareShare
ReportReport
Posted on by 817

Hi all,

 

I'm at the end of a flow, but I'm having a problem getting record ID as I need to use it into create new record action with a lookup field.

 

I'm first initializing variable ste

Radoslavov_0-1612434763847.png

Then searching inside CDS for an existing webinar, once have found the webinar I'm passing the webinar into an Appends value to an array variable. 

 

Later in the flow, I'm having a condition where I need to use the CDS webinarid value, but I have access neither to the webinar properties nor the value that I passed to the array step.

Radoslavov_0-1612435226454.png

 

Any help is appriaciated

 

Regards

Kiril

 

 

Categories:
  • Radoslavov Profile Picture
    817 on at
    Re: Get record id from CDS

    Yes, that way it worked.

     

    I've changed the expression in the Compose step to 

     

    first(outputs('List_CRM_Webinars')['body']['value'])

     

    Capture.PNG

    Then  removed and recreated for the No path the Create new registered user step, but outside of the loop, and for the webinar filed I've used the expression

     

    first(outputs('List_CRM_Webinars')['body']['value'])['new_webinarsid']

     

    Capture.PNG

    Appreciate your help with this struggle 😀

    Regards

    Kiril

  • Verified answer
    Paulie78 Profile Picture
    8,407 Super User 2025 Season 1 on at
    Re: Get record id from CDS

    I'd say it is because your apply to each is running twice (based on your run history above). I think you probably don't need any apply to each loops (based on what you have said). You can adapt the code I gave you above and use that as the basis for your record creation. You see this:

    first(outputs('List_CRM_Webinars')['body']['value'])['new_webinarsid']

    Gets just the webinarsid from your first record, but this:

    first(outputs('List_CRM_Webinars')['body']['value'])

    Would give you everything from that record. If you used this as the basis for your no condition instead of the array (which is only every going to contain one record). Then you would have no need of an apply each.

    You would probably lose the dynamic content, but you could easily pass the output of:

    first(outputs('List_CRM_Webinars')['body']['value'])['new_webinarsid']

    Into a parse JSON step, which would make it easy for you to select dynamic content again and would remove all of the apply/each steps as it would no longer be an array, but an object.

  • Radoslavov Profile Picture
    817 on at
    Re: Get record id from CDS

    It's workiiiiiiiiing 🤗

     

    Radoslavov_0-1612786449062.png

    I'm just wondering why there are two records created (both exactly the same)

     

    Radoslavov_1-1612786640847.png

    Radoslavov_2-1612786719603.png

    Radoslavov_3-1612786773497.png

    Radoslavov_4-1612786871969.png

     

     

  • Paulie78 Profile Picture
    8,407 Super User 2025 Season 1 on at
    Re: Get record id from CDS

    Try this instead: 

    first(outputs('List_CRM_Webinars')['body']['value'])['new_webinarsid']

     

  • Radoslavov Profile Picture
    817 on at
    Re: Get record id from CDS

    Nope, now i have this error:

    Unable to process template language expressions in action 'Compose_for_CRM_Webinar' inputs at line '1' and column '27619': 'The template language function 'first' expects its parameter be an array or a string. The provided value is of type 'Object'. Please see https://aka.ms/logicexpressions#first for usage details.'.

    Radoslavov_0-1612784118928.png

     

  • Paulie78 Profile Picture
    8,407 Super User 2025 Season 1 on at
    Re: Get record id from CDS

    Try:

    first(body('List_CRM_webinars'))['value'][0]['new_webinarsid']
  • Radoslavov Profile Picture
    817 on at
    Re: Get record id from CDS

    Hi @Paulie78 ,

     

    I've done this:

     

    Radoslavov_0-1612781202589.png

     

    first(body('List_CRM_webinars')['new_webinarsid'])

    But i'm getting the following error message

    Unable to process template language expressions in action 'Compose_for_CRM_Webinar' inputs at line '1' and column '27619': 'The template language expression 'first(body('List_CRM_webinars')['new_webinarsid'])' cannot be evaluated because property 'new_webinarsid' doesn't exist, available properties are '@odata.context, value'. Please see https://aka.ms/logicexpressions for usage details.'.

    Radoslavov_1-1612781248368.png

     

    But the field actually exists and the name is correct as I copy it from the outputs

    Radoslavov_2-1612781307916.png

    Am I doing something wrong?

     

  • Paulie78 Profile Picture
    8,407 Super User 2025 Season 1 on at
    Re: Get record id from CDS

    I would take a slightly different approach. Take your Find Webinar step out of the "apply each" loop. Then use a compose step and use the first expression to get the first (and only) record from that array. Your compose step will then contain the record that you want to reference. If you want it to contain only the webinar ID you could do something like:

     

    first(body('Find_webinar')['fieldName']

    This will then give you something you can easily refer to in the remainder of the flow.

  • Radoslavov Profile Picture
    817 on at
    Re: Get record id from CDS

    actually, there is a record 

    Radoslavov_0-1612599378697.png

       
    "body": {
            "@odata.context""https://europe-002.a/items",
            "value": [
                {
                    "@odata.id""https://org)",
                    "@odata.etag""",
                    "ItemInternalId""337fc7fb-c966-eb11-a812-000d3a44cde6",
                    "_owningbusinessunit_value""59bcc528-5652-eb11-bb23-000d3a45b8a0",
                    "_owningbusinessunit_type""businessunits",
                    "new_webinarsid""337fc7fb-c966-eb11-a812-000d3a44cde6",
                    "statuscode"1,
                    "_statuscode_label""Active",
                    "_createdby_value""e771ddb1-8e52-eb11-bb23-000d3a45b8a0",
                    "_createdby_type""systemusers",
                    "timezoneruleversionnumber"0,
                    "new_startdate""2021-02-15T10:00:00Z",
                    "_ownerid_value""e771ddb1-8e52-eb11-bb23-000d3a45b8a0",
                    "_ownerid_type""systemusers",
                    "modifiedon""2021-02-04T09:18:51Z",
                    "_modifiedby_value""e771ddb1-8e52-eb11-bb23-000d3a45b8a0",
                    "_modifiedby_type""systemusers",
                    "versionnumber"5486179,
                    "new_name""CRM integration",
                    "createdon""2021-02-04T09:18:51Z",
                    "statecode"0,
                    "_statecode_label""Active"
                }
            ]
        }
    }
  • Mira Ghaly Profile Picture
    11,409 Super User 2025 Season 1 on at
    Re: Get record id from CDS

    @Radoslavov

    I think this might be because there is no records return from List CRM webinars, can u check the flow run history if there is returned values and if so we Can add a condition to check if the list records has returned value or not

     

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Automate - Process Mining

Overall leaderboard