cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate I
Advocate I

How to generate a code based on user data input

Hi,

 

I'm building a customized Sharepoint form in PowerApps and what I want to do is have a Sharepoint text field that is being populated by PowerApps based on the values which the user inputs in the PowerApps form. Something similar to Sharepoint calculated column, but being done by PowerApps.

 

This is how the calculated column function (column Code) would look in Sharepoint list: =Text(Created, "[$-en-US]ddmmyy")&Upper(Left(Country, 3))&Text(Created, "[$-en-US] ss")&Number

 

So the form in Powerapps will have the fields:

 

-Country

-Number

 

The Created column is the time of data creation (submiting the form in PowerApps).

 

How to setup powerapps to automatically generate the data for column Code ?

 

Cheers

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: How to generate a code based on user data input

@nikola_bgd 

Excellent!

Yes, the space is in your text format.  Change the formula to this:

Text(Now(),"[$-en-US]ddmmyy") & Upper(Left(ComboBox1.Selected.Country,3)) & Text(Now(),"[$-en-US]ss") & DataCardValue29.Text
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

10 REPLIES 10
Highlighted
Super User III
Super User III

Re: How to generate a code based on user data input

@nikola_bgd 

Based on what I read in your post, you will have a PowerApp that will have an EditForm in it.  In that form, users can enter a country and a number.  Then when submitted, the Code column should contain a combined text value of the date creating, the country, the seconds of the current time, and the number entered.

 

My first question would be this - are Country and Number columns in your SharePoint List?

If so, then you will have these (country and number) columns in your EditForm.  You need to find out their entry control names within the form datacards.  So, expand the datacard in the left tree view, look for the DataCardValuexx name for both the Country and the Number datacards.

Then, for your Code column datacard in the EditForm (first unlock it) then set the Update property to:

Text(Now(), "[$-en-US]ddmmyy") & Upper(Left(DataCardValuexx.Text, 3)) & Text(Now(), "[$-en-US] ss") & DataCardValueyy.Text

Replace the DataCardValuexx with the control for the Country, and replace DataCardValueyy with the control for the Number.

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
Advocate I
Advocate I

Re: How to generate a code based on user data input

Hi @RandyHayes ,

 

Thanks for your help!

 

I've tried to change the code but still get some errors:

- Name isn't valid

- The function left has some invalid arguments

 

This is the code:

Text(Now(), "[$-en-US]ddmmyy") & Upper(Left(ComboBox1.Selected.Text, 3)) & Text(Now(), "[$-en-US] ss") & DataCardValue29.Text

 

Basically there's an issue with: Upper(Left(ComboBox1.Selected.Text, 3))

 

It refers to a choice card..

Highlighted
Super User III
Super User III

Re: How to generate a code based on user data input

@nikola_bgd 

So then considering your response, I can assume that Country is a Choice Column.

 

If that is the case then change your formula to the following:

Text(Now(), "[$-en-US]ddmmyy") & Upper(Left(ComboBox1.Selected.Value, 3)) & Text(Now(), "[$-en-US] ss") & DataCardValue29.Text
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
Advocate I
Advocate I

Re: How to generate a code based on user data input

@RandyHayes 

 

The formula still has errors:

 

1. Name isn't valid, the identifier isn't recognized

2. The funcion left has some invalid arguments

 

 

Highlighted
Super User III
Super User III

Re: How to generate a code based on user data input

@nikola_bgd 

Please provide the Items property for the ComboBox.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
Advocate I
Advocate I

Re: How to generate a code based on user data input

Hi @RandyHayes 

 

I managed to get it running:

 

Text(Now(),"[$-en-US]ddmmyy")&Upper(Left(Concat(ComboBox1.SelectedItems,Country),3))&Text(Now(),"[$-en-US] ss")&DataCardValue29.Text

 

 

Highlighted
Super User III
Super User III

Re: How to generate a code based on user data input

@nikola_bgd 

This will give you inaccurate results if you have this defined as a multi-select combobox.

But, it did give the clue I was looking for from that last reply.

Your formula should work as this:

Text(Now(),"[$-en-US]ddmmyy") & Upper(Left(ComboBox1.Selected.Country,3)) & Text(Now(),"[$-en-US] ss") & DataCardValue29.Text

 

Edit: corrected typo in the formula 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
Advocate I
Advocate I

Re: How to generate a code based on user data input

@RandyHayes 

 

It works! Thanks a lot!

 

Just one final touch, the result has a space  220519ANG 582, do you know how to fix this?

Highlighted
Super User III
Super User III

Re: How to generate a code based on user data input

@nikola_bgd 

Excellent!

Yes, the space is in your text format.  Change the formula to this:

Text(Now(),"[$-en-US]ddmmyy") & Upper(Left(ComboBox1.Selected.Country,3)) & Text(Now(),"[$-en-US]ss") & DataCardValue29.Text
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

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