cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Matt_Dahdouh
Helper III
Helper III

SubString Error

I am creating a flow that runs the following process. I need to trim the ("") off the end of the record that SalesForce is returning. I am trying to use this: 

substring(variables('varSector'),1,sub(length(variables('varSector')),12))
Matt_Dahdouh_0-1654003199439.pngMatt_Dahdouh_1-1654003252494.png
This is the output from Select Sector,
Matt_Dahdouh_2-1654003286487.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Matt_Dahdouh
Helper III
Helper III

Matt_Dahdouh_0-1654260124433.png

I have found through testing that a Combo Box will NOT accept a variable as a the Default property. A Combo Box allows you to have a variable as the default, while also having a list of options from Sharepoint.

View solution in original post

7 REPLIES 7
shoog
Dual Super User
Dual Super User

Your expression references varSector, not the output of the Select Sector action, is that correct?

Can you check the run history what varSector is set to? From the error message it appears the variable is empty/null.

Matt_Dahdouh
Helper III
Helper III

@shoog 

Yes, my expression references varSector. It will not let me have my substring under Set varSector. 

Matt_Dahdouh_1-1654007157021.png

Matt_Dahdouh_1-1654007590312.png

 

shoog
Dual Super User
Dual Super User

The Select action will return an array, so it's impossible to assign it to a string variable.

In case there could be multiple records from your source, you should place the consecutive actions in an apply to each loop.

Assuming you always expect just one result, you could use

 

substring(first(body('Select Sector')),1,sub(length(first(body('Select Sector'))),12))

 

Make sure the for the length 12 is right though, I think you intended 2 there for both of the quotes.

@shoog 

There is multiple records from the source, which gets filtered in the Select Action, down to the one record that is identified. I need to do this for a number of fields. This just happens to be the first one.

shoog
Dual Super User
Dual Super User

The Select action selects which fields you want to keep from an array of objects, it will not reduce the number of items in the array.

If you want to filter, please use the Filter array action instead to make sure you always end up with 1 record, the expression in my previous reply will work as long there is just 1 record output from the Select action.

Matt_Dahdouh
Helper III
Helper III

Matt_Dahdouh_0-1654260124433.png

I have found through testing that a Combo Box will NOT accept a variable as a the Default property. A Combo Box allows you to have a variable as the default, while also having a list of options from Sharepoint.

shoog
Dual Super User
Dual Super User

@Matt_Dahdouh  I think your last reply is in the wrong topic, this one is about a flow, not a canvas app.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (3,901)