Primary Name field is by default "Required". How to fill this field by GUID or random number on save?

- 22,364
- 14
- 59
- 168

- 569
- 6
- 16
-
Which option you endup with? – Arun Vinoth-Precog Tech - MVP Feb 06 '19 at 15:49
2 Answers
Codeless solution: You can mark that field as not a Business Required
, so you will be unblocked. You can use a codeless UI workflow to populate the Primary Name field with some fixed text. This WF can be triggered on post-create.
Code solution: Plugin can be triggered on pre-create & custom C# code can be used to pre-populate some autonumber/text in this field.
Pro tip: Model driven app is nothing but classic Dynamics CRM, so while searching for solutions use that keyword :)

- 22,364
- 14
- 59
- 168
There is a GUID() function in PowerApps that generates a random GUID. By default, its result is a GUID type of data (text, value, date, etc.).
Primary Name is a text field. To coerce the result of the GUID function to be a text string, wrap Text() around it:
Text(GUID())
So in your Patch statement or in the Update property of the field for PrimaryName, you can use the expression above to put in a GUID as a string.

- 21
- 1
-
Yes, this solution is available in Canvas apps, but in Model driven apps there's no GUID() function. If I'm correct... – Benny7500 Oct 24 '18 at 19:43