I am in the process of updating Data source of an existing PowerApps. It's previously built with D365 but now I need to change it to CDS. While working on this, I was not able to create new record (with complete data) in CRM when using SubmitForm function. It's always missing the Lookup field data, and the GUID for the Lookup field is collected on the previous screen. I found some examples to use Patch function instead and it works; however, I am also required to include all other CRM fields in Patch, plus I need to reset the fields and redirect to screen, all which SubmitForm function would've done for me in 1 line of code. So I would like to find out: is using Patch function the best practice, or is there a better and less messy way to do this?
Solved! Go to Solution.
Try simply to have the Combo Box "DefaultSelectedItems" property set to:
Filter(Contacts, Contact = GUID(Label1.Text))
Where:
Substitute "Label1" with your label that has that GUID on it
Substitute "Contacts" with your data source from CDS
And Contact being probably the same in your case
See image below as well for test result success:
And when Contact B is selected from Gallery to test:
Notice also, GUID are slightly different in both images above.
You should be able to use SubmitForm with CDS data source. In fact, we often found CDS as the best connector.
You are converting from Dynamics connector to CDS. You may need to check more carefully the guid collected in previous screen you mentioned. Make sure the data source is changed everywhere, it may be easy to forget a few and it is still referencing the now invalid data source.
Also, if you are not doing it already, you should completely remove the Dynamics 365 data source (in a new dev copy of the app) and make it so it shows Formula errors every time you are still using the Dynamics 365 data source. It is possible you're using both at same time, which is not good even if the app for some reason "works" with both data sources in there. When you are migrating, you need to cleanly remove the Dynamics 365 source in a dev copy, in the meantime the live version should use Dynamics 365 until you are ready with a completely migrated CDS data source version of the PowerApp.
Also, we recommend you do not attempt to keep the same name of the data source as the old one. Recommend you make a new data source, do not attempt to force it to take the old name, make sure red X's show up, and go manually change everywhere the old name is to the new name and review each function manually for any relevant changes.
Thank you for your quick response, @poweractivate !!
1) previous I have used a text field in PowerApps to capture the contactid from the previous screen. When I use SubmitForm function with CDS, it shows error 'value must be a data entry record' under the text field and would not create CRM record (see attached image). Could you please give me guidance on how to overcome this error?
2) because I have other apps in the same environment using D365 Data source, I am not able to remove this Data source just yet. However, I can see from this app, all the Data source shows CDS and not D365. Would this be sufficient to what you are referring to?
3) when I changed the Data source from D365 to CDS (by removing the D365 data sources and then add the CDS data sources), it doesn't give me an option to rename the data sources, and the new ones happen to be in the same name as the discarded ones. Not sure what to do here?!
Thank you.
Jessica
Yes I have cloned the original PowerApp to a new one under the same environment and then remove old data source and add new CDS data source. So we are safe there!! I have followed the instruction to make sure Settings is configured correctly for CDS.
Unfortunately there is no other error under Formulas in this case (see attached image)! I have resolved all other issues or errors that had come up during this process. One thing to mention, I am re-using all fields and layout from the existing PowerApps, so as you can see from the attached image, that custom field is with Guid number in the text field, and that's how it worked in the original app with D365. If I were to remove and re-add that field, it would turn into a drop-down list, which I am also not able to figure out as to how to insert the pre-collected data (Guid) to save in CRM.
Please advise.
Thank you.
Instead of a hard GUID are you allowed to just use a ComboBox instead and have someone select the Contact?
Or is this not allowed in your business requirements?
You are correct, due to business logic, we have created a previous page that shows a collections of Contacts that the logged in user owns and follows. Given this is a project to fix up just the Data source, I am hoping that we keep the original screen flow unless I absolutely needs to modify. So how would you set the selected value of the combo box if you know the Guid and still able to write to CRM correctly?
Try simply to have the Combo Box "DefaultSelectedItems" property set to:
Filter(Contacts, Contact = GUID(Label1.Text))
Where:
Substitute "Label1" with your label that has that GUID on it
Substitute "Contacts" with your data source from CDS
And Contact being probably the same in your case
See image below as well for test result success:
And when Contact B is selected from Gallery to test:
Notice also, GUID are slightly different in both images above.
I have marked your last reply as the solution for my post!
Thank you again for your help!!
Power Apps User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.
Did you miss the call?? Check out the Power Apps Community Call here!
User | Count |
---|---|
254 | |
203 | |
75 | |
37 | |
33 |
User | Count |
---|---|
330 | |
214 | |
123 | |
71 | |
54 |