Can I use a switch statement to send a different value to my sql database?
I have a data card that sends the username to the sql table. However, I need to push a different user value.
Example:
ContactIDLog = username (Frank E Stein)
I want it to switch the username to Frank E Steing LOGGED
I need to do this for all users who log in and the switch will provide the different username based on who is logged in.
I'm not using a drop down because I don't ask users to select their username. I simply provide it.
Thanks.
Solved! Go to Solution.
For now I'll presume you have the field on the form, but that specific data card or field is set to not be editable on the Form. If so, I presume you use the Default property of the Data Card to decide what value is on the Form (and thus, what will be sent).
I'll also presume for now that it's possible to tell who is logged in or not by checking it somewhere in your database, with something like a simple LookUp.
So if that's the case:
First, use a variable for the username data card's Default, instead of a hard coded value
varUsername
Just prior to the submit (i.e. this is usually done on the OnSelect property of your Submit button) you can perform a Lookup against your data source to check if they are logged in, assuming you have a way to do this, and then set the variable value accordingly.
Now, on the OnSelect property of your Submit button
//pseudocode
Set
(
varUsername
,If
(
Lookup(...).Logged_in
,"whateverYouWant" & "(LOGGED)"
,"whateverYouWant"
)
)
The above should be modified for your scenario.
Check if it helps @GeminiWorks
For now I'll presume you have the field on the form, but that specific data card or field is set to not be editable on the Form. If so, I presume you use the Default property of the Data Card to decide what value is on the Form (and thus, what will be sent).
I'll also presume for now that it's possible to tell who is logged in or not by checking it somewhere in your database, with something like a simple LookUp.
So if that's the case:
First, use a variable for the username data card's Default, instead of a hard coded value
varUsername
Just prior to the submit (i.e. this is usually done on the OnSelect property of your Submit button) you can perform a Lookup against your data source to check if they are logged in, assuming you have a way to do this, and then set the variable value accordingly.
Now, on the OnSelect property of your Submit button
//pseudocode
Set
(
varUsername
,If
(
Lookup(...).Logged_in
,"whateverYouWant" & "(LOGGED)"
,"whateverYouWant"
)
)
The above should be modified for your scenario.
Check if it helps @GeminiWorks
Thank you very much.
I am coming back on this one. The solution made sense to me so I accepted. However, now that I am working on my app, PowerApps does not recognize varUsername as valid. I tried the card default and the log default. Any idea on why varUsername is not recognized? It only recognizes var_Contact and VarP.
User | Count |
---|---|
260 | |
110 | |
89 | |
53 | |
44 |