Here is the If statement:
If(
IsBlank(txtExtraTotalHours),
Notify("Please enter total hours."),
IsBlank(txtExtraComments),
Notify("Please enter a comment."),
Value(txtExtraTotalHours.Text) > difference,
Notify("Total hours can not exceed the total hours between the selected dates. Please choose a correct total hours option."),
Set(
varExtraIncrement,
varExtraIncrement + 1
),
Reset(txtExtraTotalHours) && Reset(txtExtraComments),
Collect(
DowntimeRecords,
{
BusAreaColl: txtExtraBusinessArea.Text,
CountryColl: dpdExtraCountry.SelectedText.Value,
LocationColl: dpdExtraLocation.SelectedText.Value,
AffectedSystemColl: txtExtraAffectedSystem.Text,
StartDateColl: txtExtraStartDate.Text,
EndDateColl: txtExtraEndDate.Text,
TotalHoursColl: txtExtraTotalHours.Text,
TowerColl: txtExtraTower.Text,
CommentsColl: txtExtraComments.Text,
IncidentNumberColl: txtExtraIncidentNumber.Text,
UpdatedByColl: txtExtraUpdatedBy.Text,
RecordNumberColl: txtExtraRecNumber.Text
}
)
);
The last two conditions, Reset the text inputs and the Collect function aren't working correctly. If I put the Reset code below the Collect code, the Collect function works but the text inputs don't reset, and vice versa. For some reason, whatever the default condition is in this If statement, it won't execute. Any ideas as to where I am going wrong would be great. Thanks!
Solved! Go to Solution.
Hi @Anonymous ,
Based on the formula that you mentioned, I think there is somthing wrong with it. In addition, you could not put the Reset(...) formula before the Collect(...) function.
If you put the Reset(...) formula before the Collect(...) function, when the Reset(...) function is executed, the txtExtraTotalHours.Text formula and txtExtraComments.Text formula would return blank, then when you execute the Collect function, it would save blank value to your TotalHoursColl column and CommentsColl column in your DowntimeRecords collection.
I have made a test on my side, please consider modify your formula as below:
If( IsBlank(txtExtraTotalHours), Notify("Please enter total hours."), IsBlank(txtExtraComments), Notify("Please enter a comment."), Value(txtExtraTotalHours.Text) > difference, Notify("Total hours can not exceed the total hours between the selected dates. Please choose a correct total hours option."), Set( varExtraIncrement, varExtraIncrement + 1 ); /* <-- Type ; rather than , */ Collect( DowntimeRecords, { BusAreaColl: txtExtraBusinessArea.Text, CountryColl: dpdExtraCountry.SelectedText.Value, LocationColl: dpdExtraLocation.SelectedText.Value, AffectedSystemColl: txtExtraAffectedSystem.Text, StartDateColl: txtExtraStartDate.Text, EndDateColl: txtExtraEndDate.Text, TotalHoursColl: txtExtraTotalHours.Text, TowerColl: txtExtraTower.Text, CommentsColl: txtExtraComments.Text, IncidentNumberColl: txtExtraIncidentNumber.Text, UpdatedByColl: txtExtraUpdatedBy.Text, RecordNumberColl: txtExtraRecNumber.Text } ); /* <-- Type ; rather than , */
Reset(txtExtraTotalHours); /* <-- Put your Reset(...) formula here */
Reset(txtExtraComments) /* <-- Put your Reset(...) formula here */ )
Note: The '&&' operator used to join multiple Logic condition. The ; operator used to separate invocations of functions in behavior properties. Please check this article for more details about the difference between ; (formula chain) and && (Logic operators).
Please consider take a try with above solution, then check if the issue is solved.
Best regards,
Hi @Anonymous ,
Are you trying to reset the TextInput Field once a collection is created?
Please change your code to:
If( IsBlank(txtExtraTotalHours), Notify("Please enter total hours."), IsBlank(txtExtraComments), Notify("Please enter a comment."), Value(txtExtraTotalHours.Text) > difference, Notify("Total hours can not exceed the total hours between the selected dates. Please choose a correct total
hours option."), Set( varExtraIncrement, varExtraIncrement + 1 ), Collect( DowntimeRecords, { BusAreaColl: txtExtraBusinessArea.Text, CountryColl: dpdExtraCountry.SelectedText.Value, LocationColl: dpdExtraLocation.SelectedText.Value, AffectedSystemColl: txtExtraAffectedSystem.Text, StartDateColl: txtExtraStartDate.Text, EndDateColl: txtExtraEndDate.Text, TotalHoursColl: txtExtraTotalHours.Text, TowerColl: txtExtraTower.Text, CommentsColl: txtExtraComments.Text, IncidentNumberColl: txtExtraIncidentNumber.Text, UpdatedByColl: txtExtraUpdatedBy.Text, RecordNumberColl: txtExtraRecNumber.Text } ) ); If(!IsBlank(txtExtraTotalHours) && !IsBlank(txtExtraComments),Reset(txtExtraTotalHours) && Reset(txtExtraComments))
----------------------------------------------------------------------------
Thanks,
K-A-R-L
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If you thought this post was helpful, please give it a Thumbs Up.
I think it could be the structure you're writing it in. The if statement goes as followed:
If( Condition1, ThenResult1 [, Condition2, ThenResult2, ... [ , DefaultResult ] ] )
Only the last one is a default which should be executed. I suppose you're last three lines (Set, Reset and Collect) should be part of the default. The function will now see the Set function as an If statement and the Reset function as the code to run when the Set is ture, and else the Collect fucntion will run.
You'll have to put these all in one block after the comma for the default if you want all of them to run by putting in a ';' for a new line of code:
If( IsBlank(txtExtraTotalHours), Notify("Please enter total hours."), IsBlank(txtExtraComments), Notify("Please enter a comment."), Value(txtExtraTotalHours.Text) > difference, Notify("Total hours can not exceed the total hours between the selected dates. Please choose a correct total hours option."), Set( varExtraIncrement, varExtraIncrement + 1 ); Reset(txtExtraTotalHours) && Reset(txtExtraComments); Collect( DowntimeRecords, { BusAreaColl: txtExtraBusinessArea.Text, CountryColl: dpdExtraCountry.SelectedText.Value, LocationColl: dpdExtraLocation.SelectedText.Value, AffectedSystemColl: txtExtraAffectedSystem.Text, StartDateColl: txtExtraStartDate.Text, EndDateColl: txtExtraEndDate.Text, TotalHoursColl: txtExtraTotalHours.Text, TowerColl: txtExtraTower.Text, CommentsColl: txtExtraComments.Text, IncidentNumberColl: txtExtraIncidentNumber.Text, UpdatedByColl: txtExtraUpdatedBy.Text, RecordNumberColl: txtExtraRecNumber.Text } ) );
Could you see if this works?
Hi @K-A-R-L
Yes, the default conditions once all other error handling has been checked are Set, Reset and Collect. By concatenating these into a single default condition, could I use && between each of these?
I will try your solution and see if it works. Thanks!
The && is for conditions, to see if this AND that is true. To run the next line of code is to simply put ';' after each line.
Hi @Anonymous ,
Based on the formula that you mentioned, I think there is somthing wrong with it. In addition, you could not put the Reset(...) formula before the Collect(...) function.
If you put the Reset(...) formula before the Collect(...) function, when the Reset(...) function is executed, the txtExtraTotalHours.Text formula and txtExtraComments.Text formula would return blank, then when you execute the Collect function, it would save blank value to your TotalHoursColl column and CommentsColl column in your DowntimeRecords collection.
I have made a test on my side, please consider modify your formula as below:
If( IsBlank(txtExtraTotalHours), Notify("Please enter total hours."), IsBlank(txtExtraComments), Notify("Please enter a comment."), Value(txtExtraTotalHours.Text) > difference, Notify("Total hours can not exceed the total hours between the selected dates. Please choose a correct total hours option."), Set( varExtraIncrement, varExtraIncrement + 1 ); /* <-- Type ; rather than , */ Collect( DowntimeRecords, { BusAreaColl: txtExtraBusinessArea.Text, CountryColl: dpdExtraCountry.SelectedText.Value, LocationColl: dpdExtraLocation.SelectedText.Value, AffectedSystemColl: txtExtraAffectedSystem.Text, StartDateColl: txtExtraStartDate.Text, EndDateColl: txtExtraEndDate.Text, TotalHoursColl: txtExtraTotalHours.Text, TowerColl: txtExtraTower.Text, CommentsColl: txtExtraComments.Text, IncidentNumberColl: txtExtraIncidentNumber.Text, UpdatedByColl: txtExtraUpdatedBy.Text, RecordNumberColl: txtExtraRecNumber.Text } ); /* <-- Type ; rather than , */
Reset(txtExtraTotalHours); /* <-- Put your Reset(...) formula here */
Reset(txtExtraComments) /* <-- Put your Reset(...) formula here */ )
Note: The '&&' operator used to join multiple Logic condition. The ; operator used to separate invocations of functions in behavior properties. Please check this article for more details about the difference between ; (formula chain) and && (Logic operators).
Please consider take a try with above solution, then check if the issue is solved.
Best regards,
Thank you @v-xida-msft , @SkiDK and @K-A-R-L for your help. The semicolon solution worked well. I appreciate it!