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
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 tips 768x460 v2.png

Restore a Deleted Flow

Did you know that you could restore a deleted flow? Check out this helpful article.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Users online (3,491)