cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Setting dynamic values to a CDS entity

Hello,

 

I am looking to read data from a CDS record and create another record based on a different entity.  If the trigger CDS entity has 10 fields and if all the fields are not Null, i can map those fields directly to the new record i have to create. However in most scenarios, not all of the 10 fields will have values in them. In such cases how do i set the values to the new record using the create record or update record action? I have tried to check for null values in the triggering record and set the values to a variable and assign the variable to the create record action. However that results in an error too if the value is null. 

 

Below is the error that i get if i assign a variable that has a null value at run time to a CDS Create record action. 

Service Flow Error 1.PNG

 

Below is my flow where i am initializing a variable "Departure Date" with null and checking if the trigger record has a value and if yes, assign that value to the "Departure Date" variable and in my Create Record action, i am assigning the variable to the field Departure Date: 

Service Flow 1.PNGService Flow 2.PNGService Flow 3.PNG

 

Any suggestions how i could handle this error at runtime without have to check for each field and update them in separate actions? Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Hi @Nithin_Vanam,

 

The Date field can't be set to null, as a workaround, you could set it to an allowed minimum time '01/01/1793':

 

if(equals(length(variables('Date')),0),'01/01/1793',variables('Date'))

 

If it is a text field, you could use the blank instead:

 

if(equals(length(variables('Text')),0),' ',variables('Date'))

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Community Support
Community Support

Hi @Nithin_Vanam,

 

If date field of Create a new record action has a variable, it should has a valid date, or it will report error.

As a workaround, you could create a condition before create item, if the Date fields have a valid date, append the data field into the Create a new record action, OR create a branch that Create a new record without data field appended.Annotation 2020-04-17 170612.png

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Highlighted

Hi Nithin,

 

For datetime field please try doing this :

 

https://www.agileo365.com/2019/03/blanking-out-date-fields-in-dynamics.html?m=1

 

Thanks

Highlighted

Hi @v-litu-msft ,

 

Thanks for your input. I can certainly check for each of the data fields for a null value and set them through individual Create Record actions. However as i have about 7 date fields, that would mean 7 different Create Record actions. I am trying to avoid this if possible and still be able to perform all the updates within one action.

And it is not just about a date field but other fields too. I want to be able to assign fields in a Create Record action with some value being null without updating the field with a null value(as though i am not passing any value). The reason is there are several cases where quite a lot of the fields in the CDS entity are optional and might have a value to update. I am trying to avoid checking if each value is not null and only then update that field though a Create record / Update record actions. 

 

Is there a way to achieve this?  Thanks.

 

Regards,

Nithin

Highlighted

Hi Manish,

 

I am not trying to null a date field but its good to know how to do it. Thanks for that.

 

Regards,

Nithin

Highlighted

Hi @Nithin_Vanam,

 

The Date field can't be set to null, as a workaround, you could set it to an allowed minimum time '01/01/1793':

 

if(equals(length(variables('Date')),0),'01/01/1793',variables('Date'))

 

If it is a text field, you could use the blank instead:

 

if(equals(length(variables('Text')),0),' ',variables('Date'))

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (8,238)