I have a patch statement below,
What I need:
#1 -- I need to make sure a textbox(txt_Track) has a value in it(not blank/null etc..)
before executing the patch.
#2 -- If the "txt_Task" isBlank, throw an error statement(Notify).cancel patch
This should work, but need notify:
If(!IsBlank(Trim(txt_TrackCode.Text)), Patch(
t_nsc_trackcode_assigned_DataEntry,
Defaults(t_nsc_trackcode_assigned_DataEntry),
{
ID_Racfid: lbl_Racfid.Text,
Track_Code: txt_TrackCode.Text,
Seller_Name: txt_TC_Name.Text,
Director_Name: txt_Director.Text,
Track_Name: txt_TC_Name.Text,
Opened_Date: DateTimeValue(txt_OpenedDate.Text),
Expected_Completed_Date: DateTimeValue(txt_Expected_Completed_Date.Text),
Status: dwn_Status.Selected.Value,
Originated_From: "Field",
Notes: rte_Notes.HtmlText,
Activity_Task: dwn_Tasks.Selected.Activities_and_Tasks,
Col_Id_Template: dwn_Tasks.Selected.Column_ID,
Expedited:If(chk_Expedite.Value = true,"YES","NO"),
subcategory_id: dwn_SubTasks.Selected.SubCat_ID
}
);
Reset(chk_Csp_SalesForce);
Reset(chk_Csp_Quote);
Reset(cbo_ComboSearch);
Reset(txt_TrackCode);
Reset(txt_TC_Name);
Reset(txt_Seller);
Reset(txt_Director);
Reset(rte_Notes);
Reset(dwn_Tasks);
Reset(dwn_Status);
Notify("Track Added",NotificationType.Success,2000));
Solved! Go to Solution.
Hi @DAVIDPOWELL
You might want to consider a different approach to this. While in traditional applications the method was to allow the user to hit a button and then tell them everything they did wrong, with PowerApps (and Apps in general), a more modern method is to limit the ability for the user to press the button in the first place.
So perhaps set the DisplayMode property on your submit button to the following:
If(IsBlank(Trim(txt_TrackCode.Text)), Disabled, Edit)
The button would not be enabled unless the field is complete.
You could then also emphasize the "required" aspect of the txt_TrackCode to the user as they fill in the information.
Also, a little bonus if you like...in regard to all your Reset functions.
You might consider using this little handy practice.
1) Put a Toggle control on your screen (you probably would want to make it not Visible) Let's call it tglResetForm
2) Set the OnCheck formula of the toggle to the following: UpdateContext({resetForm:false})
3) Set the Default property of the toggle to the following: resetForm
4) Now, for all of your Controls that you want to reset, set the their Reset property to tglResetForm.Value
Pull all the Reset functions out of your original formula and put in a UpdateContext({resetForm:true})
Anytime you set the resetForm variable, it will reset all the controls that "subscribe" (via the Reset property) to that toggle.
Makes it handy when your form starts to grow and you have to constantly go back to modify the formulas where you have the Resets.
Just a little extra.
I hope this is helpful for you.
Hi @DAVIDPOWELL
You might want to consider a different approach to this. While in traditional applications the method was to allow the user to hit a button and then tell them everything they did wrong, with PowerApps (and Apps in general), a more modern method is to limit the ability for the user to press the button in the first place.
So perhaps set the DisplayMode property on your submit button to the following:
If(IsBlank(Trim(txt_TrackCode.Text)), Disabled, Edit)
The button would not be enabled unless the field is complete.
You could then also emphasize the "required" aspect of the txt_TrackCode to the user as they fill in the information.
Also, a little bonus if you like...in regard to all your Reset functions.
You might consider using this little handy practice.
1) Put a Toggle control on your screen (you probably would want to make it not Visible) Let's call it tglResetForm
2) Set the OnCheck formula of the toggle to the following: UpdateContext({resetForm:false})
3) Set the Default property of the toggle to the following: resetForm
4) Now, for all of your Controls that you want to reset, set the their Reset property to tglResetForm.Value
Pull all the Reset functions out of your original formula and put in a UpdateContext({resetForm:true})
Anytime you set the resetForm variable, it will reset all the controls that "subscribe" (via the Reset property) to that toggle.
Makes it handy when your form starts to grow and you have to constantly go back to modify the formulas where you have the Resets.
Just a little extra.
I hope this is helpful for you.
That worked well and thanks for the reply ! and yes that is a better suggestion.
Still getting used to the simplicity of the methods and properties and how to utilize them.
and appreciate the bonus extra help !!
Dave
User | Count |
---|---|
254 | |
106 | |
92 | |
47 | |
37 |