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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch complex field da...
Power Apps
Answered

Patch complex field data to CDS

(0) ShareShare
ReportReport
Posted on by

Hello good morning,

 

I'm trying to patch various fields in a form but I can't patch complex values.

 

Here's my code without the complex fields (works fine):

 

Patch(TSSR; Defaults(TSSR); {'Dimensões da antena': DataCardValue3.Text; Data_de_preenchimento: DateValue1.SelectedDate; Energia: DataCardValue4.Text; 'Endereço de Correio Eletrónico': DataCardValue6.Text})

 

This is (for example) the code I'm trying to patcch with the complex field:

 

Patch(TSSR; Defaults(TSSR); {'Dimensões da antena': DataCardValue3.Text; Data_de_preenchimento: DateValue1.SelectedDate; Energia: DataCardValue4.Text; 'Endereço de Correio Eletrónico': DataCardValue6.Text; 'Criado por' : DataCardValue8.Selected. ???? (I don't know what to put because item, data or value doesn't work )})

 

Can you help me?

 

Best regards.

 

Print screen of the problem:

 

ticket patch 1.jpg

 

 

 

Categories:
I have the same question (0)
  • JasonAlmeida Profile Picture
    96 on at

    Hey Joao

     

    I'm assuming 'Criado por' is a lookup to the user entity?

    You will have to do something like this - 'Criado por' : LookUp(Users,systemuserid = DataCardValue8.Selected.systemuserid).

    Basically, 'Criado por' is expecting a record and you can provide that by looking up to the users table and finding the record that matches the selected systemuserid.

     

    Alternatively,

    If possible, you could switch your fields to use and editForm and just use a submit button to push your changes to CDS

     

    hope this helps 🙂

  • Community Power Platform Member Profile Picture
    on at

    Hello good morning,

     

    Thank you for your answer @JasonAlmeida ,

     

    The syntax is giving me errors, in the condition I'm having a problem with the expected value, I don't have the option systemuserid, instead I have: user, licence user, synchronized user, user (view), dashboard user, AD user, user exclusive id, user name and other options.

     

    Do you know what is the correct option?

     

    Thank you.

     

    Best Regards.  

  • v-xida-msft Profile Picture
    on at

    Hi @Anonymous ,

    Could you please share a bit more about the 'Criado por' field within your CDS Entity (TSSR)? Is it a Option Set column or a LookUp type column?

    Does the Edit form connect to your 'TSSR' Entity data source?

     

    The 'Criado por' field is a "Created By" field in your  'TSSR' Entity, is it true? Actually, the "Created By" field is a System field in CDS Entity, we do not need to specify a proper value for it. The "Created By" field value would be populated with current sign in user automatically by CDS System.

     

    If you specify a value for the "Created By" field, the following error message would be shown up:

    2.JPG

    so do not specify the System Field within the '{}' part of your Patch function. Please modify your formula as below:

    Patch(
     TSSR; 
     Defaults(TSSR); 
     {
     'Dimensões da antena': DataCardValue3.Text; 
     Data_de_preenchimento: DateValue1.SelectedDate; 
     Energia: DataCardValue4.Text; 
     'Endereço de Correio Eletrónico': DataCardValue6.Text
     }
    )

    Please also remove the 'Criado por' field data card from your Edit form, make sure you could not specify value for the "Created By" field.

     

    If you just want to specify a normal LookUp field or Option Set field within the "{}" part of Patch function, please take a try with the following formula:

    Patch(
     TSSR; 
     Defaults(TSSR); 
     {
     'Dimensões da antena': DataCardValue3.Text; 
     Data_de_preenchimento: DateValue1.SelectedDate; 
     Energia: DataCardValue4.Text; 
     'Endereço de Correio Eletrónico': DataCardValue6.Text;
     OptionSetField: OptionSetFieldComboBox.Selected.Value;
     LookUpField: LookUpFieldComboBox.Selected
     }
    )

    If the Edit form is connected to the 'TSSR' Entity data source, you could also modify your formula as below:

    Patch(
     TSSR; 
     Defaults(TSSR); 
     EditForm1.Updates
    )

    Note: Please remove the System fields (e.g. Created On, Created By, Modified, Modified By, ... etc) data cards from your Edit form.

     

    Best regards,

  • Community Power Platform Member Profile Picture
    on at

    Hello good morning @v-xida-msft ,

     

    Thank you for your answer.

     

    The field is the created by and yes is a standart field from the entity that is created automatically when you create a new entity.

     

    So is I put this field to read only it will be populated automatically by power apps for the user that is submitting the information through the form correct?

     

    I have the same problem with date and time fields, when I patch those fields only patch the date and the time is always 12:00 and not the input time. 

     

    I tried to add the hour and minute value in the same patch but give me an error that is not expecting more than one value, and if I try to repeat the name of the field I'm trying to patch it says that I cannot repeat the same field name. 

     

    Do you have a solution for this?

     

    Thank you very much.

     

    Best regards.

  • v-xida-msft Profile Picture
    on at

    Hi @Anonymous ,

    Which date type do you use to store the date time value in your CDS Entity? Date and Time type field or Date Only field?

     

    Yeah, you are right. The 'Created By' field would be populated with the current sign in user who submit the new entry automatically by CDS System.

     

    For your Date and Time field issue, I think it is an known issue with Date/Time type field in CDS Entity. Please make sure you have set up a "Date and Time" type field (rather than Date Only type) in your CDS Entity to store the entered date and time value in your canvas app.

    Please check and see if the following blog about Data and Time field in CDS would help in your scenario:

    https://powerapps.microsoft.com/en-us/blog/working-with-time-zones-in-the-common-data-service/

     

    Please take a try with above solution, then check if the issue is solved on your side.

     

    Best regards,

  • Community Power Platform Member Profile Picture
    on at

    Hello good afternoon @v-xida-msft ,

     

    Thank you for your answer.

     

    Yes, I have a field type of date and time, I read the page that you send me but didn't solved the problem still can't patch the time, only the date.

     

    The time that is shown is not correct.

     

    Do you have any other input how to solve this?

     

    Best Regards.

  • Verified answer
    v-xida-msft Profile Picture
    on at

    Hi @Anonymous ,

    Based on the issue that you mentioned, I think there is something wrong with the Date time configuration in your CDS Entity.

     

    I have made a test on my side, and don't have the issue that you mentioned. On your side, please consider remove the date field from your CDS Entity. Then re-add a new Date and Time type field, and configure it as below:

    1.JPGThen re-generate a new app based on your CDS Entity, then the Date and Time field would decorated as below:

    2.JPG

    Also please make sure the Date time zone setting of the DatePicker control is set to following:

    DateTimeZone.Local

    after that, submit a new entry into CDS Entity.

     

    The date time value submitted from my canvas app is stored properly in my Entity:

    3.JPG

     

    Please take a try with above solution, then check if the issue is solved.

     

    Best regards,

  • Community Power Platform Member Profile Picture
    on at

    Hello good afternoon @v-xida-msft 

     

    Thank you very much, that solved the problem.

     

    Best regards

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard