cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JamesMoyle
Frequent Visitor

The value of first parameter is of type 'Object' but the function 'substring' expects a string.

Hi All. First time caller!

I am trying to get an icalendar to update a sharepoint calendar via a scheduled flow. A really good article here that has got me most of the way there. However, my dates come from the ical in two forms. either

 

"DTSTART;VALUE=DATE:20210913"
or
"DTSTART:20210913T150000Z"
These are the outputs of a filter function called FIND_DTSTART
 
depending on whether they are just a date or date and time. I am trying to use a compose function so that they are all of the same string format
The code I am using is:
 
if(equals(substring(outputs('Find_DTSTART'),0,8),'DTSTART:'), replace(body('Find_DTSTART'),'DTSTART:',''), replace(body('Find_DTSTART'),'DTSTART;VALUE=DATE:',''))
 

So as per the title, what am I doing wrong? Why is it not picking it up as a string? 

thanks for any help you can give me

James

1 ACCEPTED SOLUTION

Accepted Solutions
JamesMoyle
Frequent Visitor

OK, so I don't fully understand why the previous code didn't work, but I have solved it. I have changed the statement to a nested replace statement so there is no now if(equals) to deal with:

 

replace(replace(first(body('Find_DTSTART')), 'DTSTART:'''), 'DTSTART;VALUE=DATE:''')
 
much neater!

View solution in original post

1 REPLY 1
JamesMoyle
Frequent Visitor

OK, so I don't fully understand why the previous code didn't work, but I have solved it. I have changed the statement to a nested replace statement so there is no now if(equals) to deal with:

 

replace(replace(first(body('Find_DTSTART')), 'DTSTART:'''), 'DTSTART;VALUE=DATE:''')
 
much neater!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (1,233)