I'm new to developing power apps and I would like to create a form. My challenge is to minimize the repetition of capturing information for the same task. For instance, if the user captures the work details for road blading with reference number P127-2, and then continues to perform the same task the next day, I don't want the user to have to enter all the information again. Instead, they should only provide a new date and the starting point should automatically be set as the previous submitted end point. The remaining information should be pre-filled by default, using the data that was previously submitted.
Hi @swelihle ,
Since it should be a customize form in SharePoint list, when users choose to create new item in the list, the form will appear on the right-hand panel. At that time, the DataCardValue45 would be blank if you have not set a default value for it. And so then the whole function OnVisible will not work at all, the variable will be blank.
You can move the formula OnVisible to OnChange of the DataCardValue45 control, so that as soon as the user typed in road number in this text input field, the variable could be generated. The formula needs a little modification, it will reset the form if a completed road, then push a notification to the user as well:
Set(
previousSubmission,
Last(Filter('Internal Blading List', 'ROAD NUMBER' = Trim(DataCardValue45.Text)))
);
If(
previousSubmission.'TOTAL ROAD LENGTH' = Round(previousSubmission.'END POINT/KM', 3),
ResetForm(Form2);Notify("This Road Is COMPLETED!",NotificationType.Error)
)
For the other data card values where you need set default values, now you can set column values of the variable.
Best regards,
THIS IS MY SHAREPOINT LIST COLUMNS
Date | Description of work being done | Road Number | Total Road Length | Start Point/ km | End Point/ km | Unit of Measure | Output achieved | Vehicle/Plant Registration | Hours Worked (if applicable) | Fuel | Comments (In particular to Variance, Corrective Action, Quality and any other pertinent information) | |
|
THIS FORM IS BASED ON ROAD TASK AND IT COULD TAKE 1 DAY OR MORE TO COMPLETE TASK, TO AVAOID USER REPEATING ENTERING SAME DATA FOR THE SAME TASK IM TRYING TO RETRIVE DATA THAT IS PREVIOUSLY STORED ON THE LIST TO THAT THE USER DOES HAVE TO RE ENTER THAT DATA IF THEYRE STILL WORKING ON THE SAME TASK
FYI
FIRSTLY IF TOTAL ROAD LENGTH = ENDPOINT - THAT MEANS THE TASK IS COMPLTED
SECOND IF ROAD SO THE FORM MUST BE BLANK FOR NEW ENTERY FOR THE NEW ROAD TASK
SECONDLY IF THE ROAD TASK IS HAVE TO BE DONE THE FOLLOWING DAY , THE END POINT OF THE PRIVIOUS DAY MUST DISPLAY AS STARTPOINT AND THE END POINT OF NEW SUBMITTION MUST BE EMPTY AS WELL AS DATE AND OTHER COLUMNS MUST POPULATE THE FORM BY DEFAULT , SO IVE USED THIS FORMULAR ON THE ONVISIBLE PROPERTY OF THE SCREEN If(
previousSubmission.'TOTAL ROAD LENGTH' = Round(previousSubmission.'END POINT/KM', 3),
ResetForm(Form2),
Set(
previousSubmission,
Last(Filter('Internal Blading List', 'ROAD NUMBER' = Trim(DataCardValue45.Text)))
)
)
AND USE previousSubmission to display data on each datacard textbox and dropbox on the form, for example if i want to populate data from the list to textbox of Vehicle/Plant Registration , i just use the variable previousSubmission , like this previousSubmission.' Vehicle/Plant Registration ' , than data is from list on the column of Vehicle/ plant is populated on datacard textbox on the from
FORMALR IS PLACED ON THE ONVISIBLE PROPERTY OF THE SCREEN
Hi @swelihle ,
Where did you place this formula? I cannot understand its logic. How did you initialize the variable previousSubmission? This formula only sets the variable or push a notification to the user based on the condition, not to mention that it will definitely report an error because of the redundant Blank().
If you want to display a number in the 'START POINT/KM' Data Card Value based on DataCardValue45.Text, TOTAL ROAD LENGTH and 'END POINT/KM, please try below formula in Default property of 'START POINT/KM' Data Card Value:
If(
previousSubmission.'TOTAL ROAD LENGTH' <> Round(previousSubmission.'END POINT/KM', 3),
previousSubmission.'END POINT/KM',
Blank()
)
To set value in the variable and push notification based on the condition, set below formula in a behavior property, such as OnChange of the DataCardValue45 which is ROAD NUMBER input field:
If(
previousSubmission.'TOTAL ROAD LENGTH' <> Round(previousSubmission.'END POINT/KM', 3),
Set(
previousSubmission,
Last(Filter('Internal Blading List', 'ROAD NUMBER' = Trim(DataCardValue45.Text)))
),
Notify("ROAD IS COMPLETED")
)
Best regards,
If(
previousSubmission.'TOTAL ROAD LENGTH' <> Round(previousSubmission.'END POINT/KM', 3),
Set(
previousSubmission,
Last(Filter('Internal Blading List', 'ROAD NUMBER' = Trim(DataCardValue45.Text)))
),
Notify("ROAD IS COMPLETED"),
Blank()
)
it working perfectly but the issue is that when previousSubmission.'TOTAL ROAD LENGTH' = Round(previousSubmission.'END POINT/KM', 3) , it still does return value to form , instead of displaying road is completed and reset the form
Hi @swelihle ,
Based on your words, users should use the App to submit new items in different days. So, the Set function could not work when they are going to raise a new form in the other day, variables could not cache in cloud. The variable previousSubmission will be lost when App is closed. My formula will work every time users log in to the App, select a 'Description of work being done' and a road number then start to fill the form.
Best regards,
If(
previousSubmission.'TOTAL ROAD LENGTH' <> previousSubmission.'END POINT/KM',
this is the fomular im currently using Set(previousSubmission, LookUp('Internal Blading List', 'ROAD NUMBER' = previousSubmission.'ROAD NUMBER')),
Blank()
) but it doesnt return anything even if the above condition is true,
LookUp('Internal Blading List', 'ROAD NUMBER' = previousSubmission.'ROAD NUMBER'): This is a function call to LookUp with two arguments. The first argument is the name of the list or table, which in this case is 'Internal Blading List'. The second argument is a condition that specifies how to filter the data in the list. It checks if the 'ROAD NUMBER' field of each entry in the list is equal to the 'ROAD NUMBER' field of the previousSubmission variable.
Set(previousSubmission, LookUp('Internal Blading List', 'ROAD NUMBER' = previousSubmission.'ROAD NUMBER'): This code assigns the result of the LookUp function to the previousSubmission variable using the Set function. The Set function is commonly used to assign a value to a variable.
im not using a excel im using a sharepoint list as my data source
Hi @swelihle ,
I assume you are using a table like in the Excel as your data source. When creating new items, users will select a
Description of work being done as well as corresponding Road Number, then they could sort the table by date descending order and get the most recent record.
First(Sort(Filter(Table, 'Description of work being done' = DescriptionDropdown.Selected.Value && 'Road Number' = RNDropdown.Selected.Value), Date, Descending))
So, in the form you want to create, any data card value controls can be set in their Default properties, bound to this record and get the column values you want. For example, starting point Text input could be set as:
First(Sort(Filter(Table, 'Description of work being done' = DescriptionDropdown.Selected.Value && 'Road Number' = RNDropdown.Selected.Value), Date, Descending)).'End point'
Best regards,
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.