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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to convert array i...
Power Automate
Answered

How to convert array item from number to string?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi!


As you see in my output, my id is a number, but I need it to be a string.

I loop through my array of 4 objects, and I can get the ID of each object, but I can't figure out how to convert it to a string and pass it along with the rest of the original object, so my final output would be the same item, just with "id" being a string!

Output.PNGOutput1.PNG

Categories:
I have the same question (0)
  • v-yuazh-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

     

    Could you please share the full array with me?

     

    Maybe you could loop though each item in the array and then create new array ( convert the id value type in this step) with each item.

     

    Best regards,

    Alice

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi Alice @v-yuazh-msft

    Thank you, I guess that could be a solution, but it's can sometimes be a semi-large array, so I was trying to avoid it to begin with, and also I wasn't sure how to do it 🙂 Here's the full array:

    [{
    "cc_emails": [
    "e@mail.com"
    ],
    "fwd_emails": [],
    "reply_cc_emails": [
    "e@mail.com"
    ],
    "fr_escalated": false,
    "spam": false,
    "email_config_id": null,
    "group_id": 43000309047,
    "priority": 2,
    "requester_id": 43016947108,
    "responder_id": 43010370736,
    "source": 3,
    "company_id": 43000502303,
    "status": 2,
    "subject": "Auto submit MS Project",
    "association_type": 2,
    "to_emails": null,
    "product_id": null,
    "id": 660,
    "type": "Change Request",
    "due_by": "2019-01-02T13:26:59Z",
    "fr_due_by": "2018-12-24T13:26:59Z",
    "is_escalated": false,
    "custom_fields": {
    "cf_automatically_approved": "Needs customer approval",
    "cf_estimate_approved_customer_only": null,
    "cf_initiate_resolution_within": null,
    "cf_end_user": null,
    "cf_estimate": null,
    "cf_estimate_lt4_hrs": "30+ hours",
    "cf_note_to_invoice": null,
    "cf_internal_software_license_assurance": null
    },
    "created_at": "2018-12-10T13:26:59Z",
    "updated_at": "2018-12-12T12:41:57Z",
    "associated_tickets_count": null,
    "tags": [],
    "description": "<div dir=\"ltr\">\n<div><strong> </strong></div>\n<div>\n<br><strong>Auto submit</strong>\n</div>\n<div><br></div>\n<div>Text sample</div>\n<div><br></div>\n<div><br></div>\n</div>",
    "description_text": "  Auto submit Text sample",
    "internal_agent_id": null,
    "internal_group_id": null
    }]


    *********
    I thought this was gonna be easy, but it turned out to be quite challenging! Thanks again 🙂

  • v-yuazh-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

     

    If you want to convert array item "id" from number to string, you could refer to screenshot below to create the flow:

    Capture.PNG

    Capture.PNG

     

    And the expression of id should be :

    items('Apply_to_each')?['id']
     
    We could formate the number type id to string type with string expression as below:
    string(items('Apply_to_each')?['id'])

    The flow would run successfully as below:

    Capture.PNG

     

    Best regards,

    Alice

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi Alice @v-yuazh-msft

    This works very well for getting the id value and converting it.
    Output2.PNG

    However I'm not sure how to put that idstring output "back into the original array", or even making a copy of the old array with the new string value? 

    As I need to send the entire array (json document) to the database, and not just the idstring value of "660" 🙂

    Output3.PNG

    Thank you for your help! 🙂 

  • Verified answer
    v-yuazh-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

     

    Please refer to screenshot below to convert the array:

    Capture.PNG

    Capture.PNG

    Capture.PNG

     

    You could enter below content in the Value field of Append to Array variable:

    {
     "cc_emails": @{items('Apply_to_each')['cc_emails']},
     "fwd_emails": @{items('Apply_to_each')['fwd_emails']},
     "reply_cc_emails": @{items('Apply_to_each')['reply_cc_emails']},
     "fr_escalated": @{items('Apply_to_each')['fr_escalated']},
     "spam": @{items('Apply_to_each')['spam']},
     "email_config_id": @{items('Apply_to_each')['email_config_id']},
     "group_id": @{items('Apply_to_each')['group_id']},
     "priority": @{items('Apply_to_each')['priority']},
     "requester_id": @{items('Apply_to_each')['requester_id']},
     "responder_id": @{items('Apply_to_each')['responder_id']},
     "source": @{items('Apply_to_each')['source']},
     "company_id": @{items('Apply_to_each')['company_id']},
     "status": @{items('Apply_to_each')['status']},
     "subject": @{items('Apply_to_each')['subject']},
     "association_type": @{items('Apply_to_each')['association_type']},
     "to_emails": @{items('Apply_to_each')['to_emails']},
     "product_id": @{items('Apply_to_each')['product_id']},
     "id": @{string(item()['id'])},
     "type": @{items('Apply_to_each')['type']},
     "due_by": @{items('Apply_to_each')['due_by']},
     "fr_due_by": @{items('Apply_to_each')['fr_due_by']},
     "is_escalated": @{items('Apply_to_each')['is_escalated']},
     "custom_fields": @{items('Apply_to_each')['custom_fields']},
     "cf_automatically_approved": @{items('Apply_to_each')['custom_fields']['cf_automatically_approved']},
     "cf_estimate_approved_customer_only": @{items('Apply_to_each')['custom_fields']['cf_estimate_approved_customer_only']},
     "cf_initiate_resolution_within": @{items('Apply_to_each')['custom_fields']['cf_initiate_resolution_within']},
     "cf_end_user": @{items('Apply_to_each')['custom_fields']['cf_end_user']},
     "cf_estimate": @{items('Apply_to_each')['custom_fields']['cf_estimate']},
     "cf_estimate_lt4_hrs": @{items('Apply_to_each')['custom_fields']['cf_estimate_lt4_hrs']},
     "cf_note_to_invoice": @{items('Apply_to_each')['custom_fields']['cf_note_to_invoice']},
     "cf_internal_software_license_assurance": @{items('Apply_to_each')['custom_fields']['cf_internal_software_license_assurance']},
     "created_at": @{items('Apply_to_each')['created_at']},
     "updated_at": @{items('Apply_to_each')['updated_at']},
     "associated_tickets_count": @{items('Apply_to_each')['associated_tickets_count']},
     "tags": @{items('Apply_to_each')['tags']},
     "description": @{items('Apply_to_each')['description']},
     "description_text": @{items('Apply_to_each')['description_text']},
     "internal_agent_id": @{items('Apply_to_each')['internal_agent_id']},
     "internal_group_id": @{items('Apply_to_each')['internal_group_id']}
    }

    The flow would run successfully as below:

    Capture.PNG

     

     

    Best regards,

    Alice

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you very much for the help! @v-yuazh-msft

    🙂

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 873

#2
Valantis Profile Picture

Valantis 813

#3
Haque Profile Picture

Haque 526

Last 30 days Overall leaderboard