cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

keep track of admin opening a form

For this app, we need to keep track of the first admin who opens a submitted form. There is a field that will display the name of the admin. 

We have an Open Request button which is only visible to the admin members. 

When an admin member view a form and click on the Open Request button, the status will change to "Open".  

 

Currently we used the function User().FullName. So, it displays the name of any current user who is viewing the form and will keep changing across users. 

 

Is there a way to declare that allows us to capture and display the name of only the first admin who opened the form upon clicking Open Request button?

 

12 REPLIES 12
eka24
Super User III
Super User III

You will need a permanent datasource with a Column that will store the First admin.

After that:

Create a variable Onselect of Open Request button:

Set(MyFirstAdmin,"Admin"&"-"&Now())

Thus whenever the buttin is clicked, the Vriable will be created.


Insert a TextBox1 and Put the variable name in the Default: MyFirstAdmin

 

Finally Patch:

  Patch(DataSource, Defaults(DataSource), { ColumnName: TextBox1.Text } )

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Anonymous
Not applicable

@eka24,Thank you for the reply. 

Actually, this is the code for OnSelect of Open Request button that displays name of any current user opening the form.

 

tempsnip3.png

 

There is a different datasource for the admin's details only. 

How should I do if I want to get the name of current admin user opening the form from a different datasource?

If you know the specific FullName or Email of the Admin, then:

 

If(varPicOpen="Johnson Joe",

Patch(DataSource, Defaults(DataSource), { ColumnName: varPicOpen} ))

Or

You can set a variable for Email:

     Set(varPicOpenAdmin,User().Email)

Then

If(varPicOpenAdmin="Johnson@ccc.com",

Patch(DataSource, Defaults(DataSource), { ColumnName: varPicOpenAdmin} ))

 

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

 

Anonymous
Not applicable

hi @eka24,

considering that admin user permission has been set in the first place, so that they can view the Open Request button.

I currently face another problem. 

continuing from before, I added variable that also capture time when the form is opened at OnSelect.

1.PNG

 

And i placed those variables at Default in the field for PIC name and time.

 

2.PNG

 

 I placed the Patch as below. When user clicked Open Request, the name and time is displayed on the form immediately.

 

3.PNG

 

However, only managed to store the time only in the data source. The name of User did not store. 

When I refresh and open the form again, it does not display anything in the fields. 

 

4.PNG

6.PNG

 

"I currently face another problem.

continuing from before, I added variable that also capture time when the form is opened at OnSelect."

 

Is the variable stored OnVisible or OnSelect of a Button?

 

Please copy and past the Patch formula for assistance

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Anonymous
Not applicable

hi @eka24 

 

The variables are at the OnSelect of Button.

 

Below is the code for Patch

 Patch('Request For Quotation', SharePointForm1.LastSubmit, {varPICopen: User().FullName, varPICopendate: Now()});  

 

In Patching to the Datasource, The column name in the tables should be involved. Your formula did not include any column name.

Also Using last submit should include the column name example LastSubmit.ID

 

If you are Using LastSubmit, then:

Patch('Request For Quotation', Defaults('Request For Quotation'), {varPICopenColumn:SharePointForm1.LastSubmit.varPICopenColumn,
   varPICopendateColumn:SharePointForm1.LastSubmit.varPICopendateColumn})

 

Or

 

If you are not using Last Submit, then:

Patch('Request For Quotation', Defaults('Request For Quotation'), {varPICopenColumn:varPICopen,varPICopendateColumn:varPICopendate})

 

The formula for the creation of the variable should be before submission.

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Anonymous
Not applicable

hi @eka24,

 

following the given code, 

Patch('Request For Quotation', Defaults('Request For Quotation'), {PICopen:SharePointForm1.LastSubmit.PICopen,
   'PICopen Date':SharePointForm1.LastSubmit.'PICopen Date'});  

 

for PICopen field default,

If(IsBlank(varPICopen), ThisItem.PICopen, varPICopen) 

 

for PICopen Date field default,

If(IsBlank(varPICopendate), ThisItem.'PICopen Date', varPICopendate) 

 

OnSelect Button,

UpdateContext({varStDt:Text(Now(),"[$-en-US]mm/dd/yyyy hh:mm:ss AM/PM"), varStatus:"Open", varPICopen: User().FullName, varPICopendate: Now()});  

 

Only the date/time is stored in data source. User name still not stored. So, on the form only can display the date/time.

11.PNG

 

I tried the OnSelect formula and it works fine.

When I click the Button, the default textbox is not Blank.

Am wondering at which point do you select the Button. I did not get blank.

 

Also in  PICopen field default,

  If(IsBlank(varPICopen), ThisItem.PICopen, varPICopen)

What does ThisItem.PICopen represent, is it a textbox?

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (68,676)