Powerapps: button selection on a previous screen prefill a field in a form - excel

I am attempting to build an app with Microsoft powerapps that will be writing/reading data to/from an excel sheet.
I have created a form in powerapps from a table in the excel sheet. I am curious to know if anyone knows how to fill the data in a field based on a button selection on a previous screen.
As an example let's say the following fields are in the form; Location, Action, Item, Username.
This is what I am imaging and would like to do;
I would like the first two fields to be filled by selecting buttons on a previous screens instead of a drop down menu in the edit form view. the last two field can be filled by inputting text on a thirds screen.
The flow:
Screen1; presents two 4 locations in the form of buttons*doesn't necessarily have to be a button but function like one.
4 locations: NY, LA, AZ, LN
when users selects "NY" button, "NY" is filled/stored in to the "location" field in the form and the screen navigates to the next page where the user will select the actions.
Screen2; presents two 2 actions in the form of button.
2 Actions: remove, add
when users selects "remove" button, "remove" is filled/stored in to the "action" field in the form and the screen navigates to the next page where the user will fill the other two fields in a text field.
Screen3; has two text fields where user can fill in the rest of the information for item and user name. Location and Action should be prefilled at this point. When the user submits the form all data is submitted and a row is created in the excel table with all the information captured.
any information how to make a button selection on a previous screen prefill a field in a form that would be awesome! thank you for reading.

It sounds like you want to use a collection. A collection can be used similar to a global variable and will allow us to access data on a different screen than the one we set it on.
Some useful information can be found here:
https://powerapps.microsoft.com/en-us/tutorials/working-with-variables/#create-a-collection
https://powerapps.microsoft.com/en-us/tutorials/function-clear-collect-clearcollect/
Based off of your flow, let's assume that the screens are named as follows:
Screen1 will be "SpecifyLocation"
Screen2 will be "SpecifyAction"
Screen3 will be "FinalizeInput"
The names are arbitrary, but I think they'll make the following example easier to follow.
On the screen "SpecifyLocation", we're going to create four buttons. They will all be identical, except for the name of the location they reference. For instance, the button referencing "NY" would be as follows:
Text = "New York"
OnSelect = ClearCollect( LocationMetadata, "NY" ); Navigate(SpecifyAction,ScreenTransition.Cover)
Please note that the OnSelect value is two different functions separated by a semicolon. The first function, ClearCollect(), clears all information in a collection and then writes a new entry. In this case, we have a collection named LocationMetadata into which we are writing the value "NY". The second function, Navigate(), changes which screen we are looking at.
On the screen "SpecifyAction", we're going to create two buttons. They will be similar, except for the action they refer to. For instance, the button referencing "Add" would be as follows:
Text = "Add"
OnSelect = ClearCollect( ActionMetadata, "Add" ); Navigate(FinalizeInput,ScreenTransition.Cover)
As was the case before, we've created a button that calls two functions when clicked. They are the same two functions as last time; however, we've changed LocationMetadata to ActionMetadata in our ClearCollect() call, since we want to store a different piece of information. We've also changed our Navigate() call to move us over to the "FinalizeInput" screen.
I'm not entirely sure how you've got your final screen laid out, but in any case, you'll want to access the data we stored in collections previously. This can be done with the function First(), which returns the first element of a collection.
To access our selected location, you can use: First(LocationMetadata).Value
To access our selected action, you can use: First(ActionMetadata).Value
You should be able to supplement whatever extra data is collected from your user on this final screen with the collections we set up.

Related

Comparing users from #username and #picklist

I have formA where I have "_reviewer" field, which is text/editable. The field is populated when the save button is clicked, the button has the following code:
pick := #Name([CN];#PickList( [Name]));
#SetField("_reviewer"; pick );
#If(#Command([FileSave]);
#Do(
#MailSend(pick;"";"";"Subject";"Body";"";[IncludeDoclink]);
#Command([CloseWindow]);
#StatusBar("Success.")
);
#StatusBar("Fail!"));
I have viewA where document should be shown if the current user is the same as the person in '_reviewer' field, the code in View Selection is:
LCName := #LowerCase(#Name([CN];#UserName));
LCPeople := #LowerCase(_reviewer);
SELECT form = "formA" & (#Contains(LCPeople; LCName))
I have another viewB, where I can see all documents, and one of the columns is '_reviewer'. Now the issue is, even though on viewB I see that John Doe is reviewer for a documentA, the documentA is not shown in viewA when John Doe is logged in as the current user. The tricky part is, documents sometimes show up in viewA, and sometimes they don't, even though I repeat the same steps when creating the document. Having this behavior is unacceptable. Is there some other way to parse the current user and the user picked from #PickList, or some other way to check if the two are the same?
Use an embedded view in a Page like suggested in your last question. This time first categorized column would be #LowerCase(_reviewer) and "Show single category" would have formula #LowerCase(#Name([CN];#UserName)). The view selection is SELECT form = "formA".
You can't use user specific functions like #UserName in public view's selection formula.
Also note, that the user can save the document by pressing Ctrl+S or by closing the window and selecting Yes when prompted. They don't have to use your Save button. If there's really something that must happen before the document is saved, it must be done in the form Querysave event. If it has to happen after the document is saved, it must be in the Postsave event. Kudos for checking the return value of the save command though!

XPages - populating multiple fields on typeahead selection

This might be a straightforward question but I can't see wood for trees at the moment
Problem: I have a typeahead attached to an edit box that looks up values from a view (based on Tim Tripcony's code). When a value is selected, I want other edit boxes on the XPage to be populated with values pulled from the corresponding document.
As an example: A username edit box has a typeahead looking up from the NAB. I select "Joe Bloggs" name from the typeahead list and want the email, phone and location edit boxes to be immediately populated with the values from his NAB entry.
I'm banging my head on the wall over this because I'm sure there's an easy and obvious solution. Thanks.
Selecting a value from the typeahead should trigger any onChange event defined for the edit box. You can set the other fields by updating the data source directly from within that event:
var selectedName = currentDocument.getValue("contactName");
currentDocument.setValue("emailAddress", getEmail(selectedName));
currentDocument.setValue("phoneNumber", getPhone(selectedName));
currentDocument.setValue("location", getLocation(selectedName));
Naturally, the above example assumes those are your field names, and that you have the named functions defined elsewhere.

Unexpected behaviour in a Lotus Notes programmable table

I'm designing a workflow database in Lotus Notes 6.0.3 (soon upgrading to 8.5), and my OS is Windows XP.
I have recently tried converting a tabbed table into a programmable one. This was so that I could control which tab was displayed to the user when it was opened, so that they were presented with the most appropriate one for that document's progress through the workflow. That part of it works!
One of the tabs features a radio button that controls visibility of the next tab, and a pair of cascading dialogue boxes. One contains the static list "Person":"Team", and the other has a formula based on the first:
view:=#If(PeerReview = "Team"; "GroupNames"; "GroupMembers");
#Unique(#DbColumn(""; ""; view; 1))
The dialogue boxes have the property "Refresh fields on keyword change" selected.
The behaviour that I wasn't expecting is this. If the radio button is set to "Yes" and a value is selected in one of the dialogue boxes, the table opens the next tab. If the radio button is set to "No" and a value is selected in one of the dialogue boxes, the entire table is hidden.
I can duplicate the latter by switching off the "Refresh fields on keyword change" property on the dialogue boxes and instead pressing F9 after selecting a value. I have no idea why the former occurs, though. The table is called "RFCInfo", and I have a field on the form called "$RFCInfo" which is editable, hidden from all users who aren't me and initially set by a Postopen script, which I can post if necessary - it's essentially a Select Case statement that looks at a particular item value and returns the name of the table row relating to that value.
Can anyone offer any pointers?
Hide-when formulas in table cells in Notes R5 and R6 were notorious for breaking in unpredictable ways when you edited the table cells. Even in R7, I think they were still a little bit funky, but by R8 they were finally really solid. You haven't shown the hide-when's but my first guess is that you are simply a victim of the bad behavior.
Please don't shoot the messenger, but the usual way we addressed this sort of problem was to painstakingly re-create the entire table from scratch, and hope we never have to edit it again. I.e., make a copy of the table in a scratch form and clear all the hide-whens -- one by one. Then create a brand new empty table in a second scratch form and get all the cells set up exactly like the original table, including nested tables, merged cells, and other settings -- but skip the hide-whens for now. Then copy each cell's content from the first scratch form to the corresponding cell of the second scratch form. Then, referring to the hide-whens in the original form, re-create each hide-when on the paragraphs in the cells on the second scratch form. Finally, delete the original table from your original form and then copy/paste the table from the second scratch from back into your original form.
Once you have R8.5, move to XPages in Notes, it's almost a no-brainer to implement your tabs. And in return, you get many other interesting issues to solve!

Dynamic Layouts in Filemaker

First off I am new to FM but I have a good handle on the basics. What I need to do is this - in a contact information type layout I want to be able to alter the layout based on a specific field. Ex. When the record is brought up, the background of the layout will change colors for a client, another for vendor, etc.
I tried to change a label based on a field, with no success. My guess is that the layout is static and only the data fields change.
We use FM Pro.
Thanks,
Mark
FileMaker layouts are static, but there are still some things you can do to alter the layout based on the values of fields:
Calculation Fields
If you want the data shown in an area to change, you can use a Calculation field. A typical example of this would be a status field. To do this you would add a new field to your table and use enter a calculation on that field like:
Case (
IsEmpty(myTable::myField) ; "Please enter a value for myField." ;
myTable::myField = "wrong value" ; "Please enter a correct value for myField." ;
"Everything seems okay."
)
Conditional Formatting
To make things like background color change you can use a conditionally formatted field. I will typically add an empty numeric field (for this example we'll call it emptyField) and set it so that it can't be edited during modification.
If you place emptyField on your layout, below all the other fields and disallow the user to enter the field in either Browse or Find mode, you can then use conditional formatting to change the field's color.
Portal Hiding
You can use this technique when you want some elements of your UI to disappear when they aren't needed. For example, if you want a "submit" button to appear only when all of the records on a field are filled out.
To use this technique I will usually create a Calculated number field, called ReadyForSubmit, on the original table and give it a logical calculation like:
not IsEmpty(field1) and ... and not IsEmpty(fieldN)
(Note that the value of the above function would be 1 or 0)
I will then create a new Support table in my database and add to it a field One with a calculated value set to 1.
I will then make a relationship between myTable::readyForSubmit and Support::One.
On the layout, create a portal with one row. Put your Submit button in that layout. Now, when readyForSubmit calculates to 1 the button will appear. When it calculates to 0 the button will be hidden.
Hidden Tab Browser
Finally, you can use a tab browser where you set the title font size to 1 point, hide the border, and control the browser programmatically. You can use this for having different field arrangements for different types of records. To do this you would first give an Object name to each tab of the tab browser, say Tab1, Tab2, Tab3.
Then you would add a script, goToTab, with the logic for when you want to go to each tab. Say:
If (myTable::myField = "corn")
Go to Object (Tab1)
Else If (myTable::myField = "squash")
Go To Object (Tab2)
End If
You would then use Script Triggers to run goToTab when On Record Load.
With the release of filemaker 13 there may be another way to do this. You could use a slide control, name the panels in the control, and conditionally switch to the correct panel based on the record type.
you would drop the appropriate fields for the record type in each panel.
http://help.filemaker.com/app/answers/detail/a_id/12012/~/using-slide-controls-and-slide-panels-in-filemaker-pro

excel spreadsheet data to web form

I'm looking to place my company's trailer inventory on a few free classified ad sites. Our inventory database (filemaker) can export data into an excel spreadsheet (column A-Make, B-Model, C-Year, etc.) including the URLs of the photos of each trailer.
Our dealer sites allow for bulk uploading through XML and that works great.
My problem is on the smaller free classified ad sites that have a web form that needs filled out (the example I'm using here has text fields and drop-down menus, but other sites have check boxes and radio buttons) then submitted for each individual trailer (about 90 trailers). I'm wondering how I can use the data in my spreadsheet to auto-fill the form with the information in row 1, submit it, re-navigate back to the form and repeat the process with the info in row 2 and so on. I know that I'm going to have to tailor my data and columns to fit each site (match column names to field names and change relevant data to match drop down options, etc.).
**edit Also (although not necessary) it would be nice if it was possible to have my photo URLs entered as well (if at all possible).
I've created a "test" account on http://www.horseclicks.com. Once logged in you have to click on "My Trailers" on the left and then the "add" button
user: excelhelp
pass: excel
Any takers??
This doesn't completely answer your question, but would save you some time entering the forms manually. If you know the names of input tags on the form you want to fill out, you can write a Javascript that will fill out the form for you: i.e., document.getElementById('your_name').value=Name[x]; etc.
In that example, Name would be an array that would contain a list of the names you wanted to put in the input field "your_name". You can easily turn an Excel sheet into a Javascript array by exporting to CSV and cut/paste into your code. Make it so that the value of x increases by 1 each time the script is ran.
Take your whole javascript, and turn it into one line that starts with "javascript:" and place this as a bookmark in your toolbar. Now you can go to the form, hit the your bookmark button and it will fill out the form. Hit submit, go back to the form, hit the button again...

Resources