cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RDJHUD
Regular Visitor

Automatically fill in a field based on 2 other fields in the entity

So, on to my next issue.  I am creating an entity that has several fields, and this entity will be a database for an inspection finding tracking system.  There are many fields, but I'm currently working on 3 text fields.  Field 1 is going to be a field that is autogenerated with information that is joined (concatenated) from Fields 2 and 3, which are both Text fields.  These fields will be inserted into a Power App Canvas app and published in Teams for my organization to have inspectors go in and enter their findings data. 

 

Field 1 - "Recommendation ID"   (This is a text field and is the Primary Name Field)

Field 2 - "Report Name"   (This is a Text field)

Field 3 - "Recommendation Number"  (This is a Text field)

 

Field 1 needs to be automatically generated by Field 2 + Field 3. 

 

Example:.

Field 2 Entry = "2020-AB-295-01"

Field 3 Entry = "01"

Desired Field 1 Auto Generated entry =  "2020-AB-295-01"

 

Is there a way to create an entity field that automatically generates Field 1 in CDS as the user enters data?  Or is there another way I'm supposed to do this?  I want to avoid having the user fill in Field 1 manually, as it is redundant work and could result in entry errors.

 

Thanks,

Randy

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @RDJHUD 

According to your description, could you tell me what kind of demand do you want?

Situation 1: you want to automatically fill in field 1 when you use canvas to edit data?

Situation 2: Do you want to automatically fill in field 1 by field 2 and field 3 ?(Automatically execute in the background not through the canvas app)

 

Situation 1: If you use canvas to edit data

1)      Firstly, you can use the UpdateIf() function to modify the existing records to what you need.

2)      Secondly, use Patch() function to submit new record when users enter information.

I've made a test for your reference:

I assume:

Users submit data by using two textinput controls and one button control.

1\ Set Apps onstart property to:

UpdateIf(Test11S,true,{'Recommendation ID':'Report Name'&"-"&'Recommendation Number'})    //Test11S is my test entity

2\ Add a textinput control TextInput1

3\ Add a textinput control TextInput2

4\ Add a button control to screen and set its onselect property to:

Patch(Test11S,
Defaults(Test11S),
{
'Report Name':TextInput1.Text,
'Recommendation Number':TextInput2.Text,
'Recommendation ID':TextInput1.Text&"-"&TextInput2.Text});
Reset(TextInput1);
Reset(TextInput2)

5\ The result is as follows:

v-bofeng-msft_3-1605151472189.png

 

 Situation 2: Use calculated fields

If you do not use canvas, primary name field cannot be automatically filled.

I suggest you add a Text field and set its calculation parameter:

v-bofeng-msft_4-1605151472191.png

 

v-bofeng-msft_5-1605151472193.png

 

Best Regards,

Bof

View solution in original post

2 REPLIES 2
EricRegnier
Super User II
Super User II

Hi @RDJHUD,

Just like in your other post, you can achieve that with calculated fields. The field will be auto-calculated real-time on retrieval of the record.

Did you give that a try? 

Cheers

v-bofeng-msft
Community Support
Community Support

Hi @RDJHUD 

According to your description, could you tell me what kind of demand do you want?

Situation 1: you want to automatically fill in field 1 when you use canvas to edit data?

Situation 2: Do you want to automatically fill in field 1 by field 2 and field 3 ?(Automatically execute in the background not through the canvas app)

 

Situation 1: If you use canvas to edit data

1)      Firstly, you can use the UpdateIf() function to modify the existing records to what you need.

2)      Secondly, use Patch() function to submit new record when users enter information.

I've made a test for your reference:

I assume:

Users submit data by using two textinput controls and one button control.

1\ Set Apps onstart property to:

UpdateIf(Test11S,true,{'Recommendation ID':'Report Name'&"-"&'Recommendation Number'})    //Test11S is my test entity

2\ Add a textinput control TextInput1

3\ Add a textinput control TextInput2

4\ Add a button control to screen and set its onselect property to:

Patch(Test11S,
Defaults(Test11S),
{
'Report Name':TextInput1.Text,
'Recommendation Number':TextInput2.Text,
'Recommendation ID':TextInput1.Text&"-"&TextInput2.Text});
Reset(TextInput1);
Reset(TextInput2)

5\ The result is as follows:

v-bofeng-msft_3-1605151472189.png

 

 Situation 2: Use calculated fields

If you do not use canvas, primary name field cannot be automatically filled.

I suggest you add a Text field and set its calculation parameter:

v-bofeng-msft_4-1605151472191.png

 

v-bofeng-msft_5-1605151472193.png

 

Best Regards,

Bof

View solution in original post

Helpful resources

Announcements
User Groups Public Preview

Join us for our User Group Public Preview!

Power Apps User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Users online (43,810)