cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Salesforce
Helper III
Helper III

Validation Error is not working on approve or reject button

Hello Team,

In powerapp , i have created a Validation error when a approver clicks on the approve / reject buttons without giving comment then a error message should reflect.It's not working.

I tried in this way

I have a Label Used --On Visible property If(!IsBlank(DataCardValue5.Text),"Field Cannot Be Blank").

Comments is a mandatory field (multiline Text).

 

Can anyone help .Any help very much appreciated.Thanks in advance.

10 REPLIES 10
VaidasG
Helper III
Helper III

Hi @Salesforce ,

 

I would go other way around this...

 

Your label text property - "Field Cannot Be Blank"

Your label Visible property - If(!IsBlank(DataCardValue5.Text), true, false)

 

... or even better, your approve / reject button onSelect property sets variable varLabelVisible to true or false, dependant on text present in comment area . Then your label Visible becomes this variable...

 

Hope this helps

Hello @VaidasG ,

Thanks for your respone.I have used the same functionality as u have mentionend.But still its not working.

On Approve / reject button --On select property --formula is been used for the status update,to capture few values

When user clicks On Approve button :

On Select property :

Set(VarStatus,"Approved");Patch(submitlist,lookup(submitlist,ID=landingpage.selected.ID),{status:{value:approved},"comments":Textinput5.Text,Date:Now())});

The Validation error should be reflected when the user clicks on approve buttons without giving comments.

Any suggestions very much appreciated.

VaidasG
Helper III
Helper III

hi @Salesforce ,

 

Why don't you wrap your button onSelect property formula, with if() statement..?

 

if(isBlank(Textinput5.Text),

    Set(varLabelVisible, true),  // blank comment field - show error message - no proceed..!

   Set(varLabelVisible, false); // not-blank - proceed with planned steps

   Set(VarStatus,"Approved");

   Patch(submitlist,lookup(submitlist,ID=landingpage.selected.ID),{status:{value:approved},"comments":Textinput5.Text,Date:Now())});
)

 

p.s. stick  Set(varLabelVisible, false) to your screens onVisible property...

 

Hope this helps

Regards

Hello @VaidasG ,

Thanks for the response.I tried the above one.It's not working.Any help very much appreciated.

VaidasG
Helper III
Helper III

Hi @Salesforce 

 

Can you a bit more specific, what is not working with the proposed solution? Maybe an error message or a screenshot...

Hello @VaidasG ,

Correct me if doing it wrong.

On Select property : Set(varLabelVisible);

I have used this formula 

if(isBlank(Textinput5.Text),
Set(varLabelVisible, true), 
{Approver Comments :"Field cannot be blank"}
 Set(varLabelVisible, false),
{Approver Comments :Textinput5.Text});


 Please find the Screenshot

Salesforce_0-1652966603850.png

when the comments field is empty ,it displaying the below screenshort

Salesforce_1-1652966656625.png

Do we need to add even On label of text and visible property.

Any help very much appreciated.Thank you. 

VaidasG
Helper III
Helper III

Hi @Salesforce ,

 

If I understood your challenge correctly, you want to show error label "Field Cannot Be Blank", when user clicks on APPROVE button if Textfield is blank, if not blank you proceed with patching etc....

 

For this scenario use variable varLabelVisible, as Visible property value for the label.

For APPROVE onSelect property set to the formula proposed earlier

 

if(isBlank(Textinput5.Text), // Checking if text input is blank
// blank block
    Set(varLabelVisible, true),  // show error message - no proceed..!
// not blank block
   Set(varLabelVisible, false); // hide error message, and proceed with the rest...
   Set(VarStatus,"Approved");
   Patch(submitlist,lookup(submitlist,ID=landingpage.selected.ID),{status:{value:approved},"comments":Textinput5.Text,Date:Now())});
)

 

 

Hope this helps 

Hello @VaidasG ,

 

On Approve button , we have a few functionlity used.

1)Status Update:On click of the Approve / reject buttons , the status will get updated.

2)Comments & Date needs to be captured with the current time and date.

3)After Clicking on the Approve button--the button will get disabled/grid out. 

this is added now

4)Validation Error:When a User does not give any comments and clicks on Approve button at that time the error msg should get displayed.In other Words its Mandatory field Comments :needs to be filled.until then the status should not get updated.

Hope u got the scenario.

Any suggestions very much appreciated.Thank you. 

VaidasG
Helper III
Helper III

@Salesforce ,

 

I think I got your scenario....

 

So, I think this is exactly what you will achieve by using code proposed.

you will condition your process on TextInput5 having text!

hmmm... 

 

Another approach - Condition DisplayMode of Button to TextInput5, so if blank disabled else edit... this way users won't be able to click on the button, unless comments left

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,986)