cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jade7669
Level: Powered On

PowerApps using CDS to create CRM record with Lookup filled by pre-collected data

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?

1 ACCEPTED SOLUTION

Accepted Solutions
dynamicsedge
Level 8

Re: PowerApps using CDS to create CRM record with Lookup filled by pre-collected data

@jade7669 

 

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:

 

DefaultSelectedItemsSetToLabelGuidRef.png
And when Contact B is selected from Gallery to test:

 

DefaultSelectedItemsSetToLabelGuidRef2.png

 

Notice also, GUID are slightly different in both images above.

 

 

View solution in original post

8 REPLIES 8
dynamicsedge
Level 8

Re: PowerApps using CDS to create CRM record with Lookup filled by pre-collected data

@jade7669 

 

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.

jade7669
Level: Powered On

Re: PowerApps using CDS to create CRM record with Lookup filled by pre-collected data

Thank you for your quick response, @dynamicsedge !!

 

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

dynamicsedge
Level 8

Re: PowerApps using CDS to create CRM record with Lookup filled by pre-collected data

@jade7669 

 

  1. The schema of CDS Connector has a subtle difference to D365 Connector in how you are using it. Can you go to the Stethoscope Icon and check if there are any other errors before submitting the form and post details here? Especially those errors under "Formulas" Subcategory
  2.  Please do not remove the data source from all places in the tenant, and please do not remove it from the production app. Instead, please make a clone of the app first that nobody is using (using Save As), with a new name, and only remove the data source from that single cloned dev app. That is what we meant when we said it first.
  3. Then let's leave that alone, but the error may be harder to find, so try #1 first and check for any other errors.
  4. Wild guesses on the issue:
    1. Somewhere in the app you may need to reference the CDS column in another way, such as using the 'Column Display Name' instead of Logical name, but again that depends what's the real cause in your case - so we would need to be sure of what is the specific error in your case.
jade7669
Level: Powered On

Re: PowerApps using CDS to create CRM record with Lookup filled by pre-collected data

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.

dynamicsedge
Level 8

Re: PowerApps using CDS to create CRM record with Lookup filled by pre-collected data

@jade7669 

 

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?

Highlighted
jade7669
Level: Powered On

Re: PowerApps using CDS to create CRM record with Lookup filled by pre-collected data

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?

dynamicsedge
Level 8

Re: PowerApps using CDS to create CRM record with Lookup filled by pre-collected data

@jade7669 

 

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:

 

DefaultSelectedItemsSetToLabelGuidRef.png
And when Contact B is selected from Gallery to test:

 

DefaultSelectedItemsSetToLabelGuidRef2.png

 

Notice also, GUID are slightly different in both images above.

 

 

View solution in original post

jade7669
Level: Powered On

Re: PowerApps using CDS to create CRM record with Lookup filled by pre-collected data

I have marked your last reply as the solution for my post!

Thank you again for your help!!

Helpful resources

Announcements
thirdimage

Power Platform 24

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors
Users online (6,003)