cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lefty
Post Prodigy
Post Prodigy

Long bit of code OnSelect of Submit button

Hello,

 

I have a problem.

I have 4 dropdown fields on my page, which i need users to enter a value, this was taken care of by the next button, as this screen was not the final screen which included the submit button, now it is, I need to add the If conditions on the OnSelect of the Submit button and I get errors further down when the second If statement appears, if i remove the 1st IF statement it works fine or if I remove the 2nd IF statement it works fine too, but if i leave it as it is , i have errors, any suggestions how i can fix this please?

 

 

If(
    IsBlank(DataCardValue75_4.Selected.Value), Notify("Select if A been informed", NotificationType.Error, 3000),
    IsBlank(DataCardValue76_4), Notify("Select if B been informed", NotificationType.Error, 3000),
    IsBlank(DataCardValue77_4), Notify("Select if C been informed", NotificationType.Error, 3000),
    IsBlank(DataCardValue78_4), Notify("Select if D been informed", NotificationType.Error, 3000),
        Set(
        vWait,
        true
    );
With(
    {vJSON:
        JSON(TakenPic,
            JSONFormat.IncludeBinaryData)},
      
      Set(
            v64Text,
            Substitute(vJSON,"""","")
        )
);

With(
    {vJSON2:
        JSON(TakenPic2,
            JSONFormat.IncludeBinaryData)},
      
      Set(
            v64Text2,
            Substitute(vJSON2,"""","")
        )
);

With(
    {vJSON3:
        JSON(TakenPic3,
            JSONFormat.IncludeBinaryData)},
      
      Set(
            v64Text3,
            Substitute(vJSON3,"""","")
        )
);

UpdateContext(
	{
	VarPatchedRecord:
	Patch(
		ListName, Defaults(ListName),
		Form1.Updates,
                Form1_1.Updates,
		Form1_2.Updates,
                Form1_3.Updates,
                Form1_4.Updates,
                Form1_5.Updates,
                Form1_6.Updates,
                Form1_14.Updates,
                {Image1:v64Text},
                {Image2:v64Text2},
                {Image3:v64Text3}
    ) 
	}
);

If(Not(IsBlank(VarPatchedRecord.ID)),Navigate(SuccessScreen);
Office365Outlook.SendEmailV2(Concat(MyApprovers,MyUser & ";"),
 "A request has been submitted by " & CurrentUser.FullName & ". The reference number is: " & VarPatchedRecord.RefNumber,
"A Form has been submitted for your assesment." & " <br>  <a href='https://apps.powerapps.com/play/URL&BI=" & VarPatchedRecord.ID & "'> You can review the request here </a> "

& "<br><br> Kind regards,
EmailGoesHere</b>",{Cc:CurrentUser.Email, Importance:"Normal"}))

 

See attached the error i get:

Lefty_0-1599664712751.png

This works fine if i remove the first IF statement, so the code is correct, i believe it's something to do with using another IF statement here?



1 ACCEPTED SOLUTION

Accepted Solutions
gabibalaban
Super User II
Super User II

From my understanding, this part is "false" branch of the first IF statement :

Set(
        vWait,
        true
    );
With(
    {vJSON:
        JSON(TakenPic,
            JSONFormat.IncludeBinaryData)},
      
      Set(
            v64Text,
            Substitute(vJSON,"""","")
        )
);

With(
    {vJSON2:
        JSON(TakenPic2,
            JSONFormat.IncludeBinaryData)},
      
      Set(
            v64Text2,
            Substitute(vJSON2,"""","")
        )
);

With(
    {vJSON3:
        JSON(TakenPic3,
            JSONFormat.IncludeBinaryData)},
      
      Set(
            v64Text3,
            Substitute(vJSON3,"""","")
        )
);

UpdateContext(
	{
	VarPatchedRecord:
	Patch(
		ListName, Defaults(ListName),
		Form1.Updates,
                Form1_1.Updates,
		Form1_2.Updates,
                Form1_3.Updates,
                Form1_4.Updates,
                Form1_5.Updates,
                Form1_6.Updates,
                Form1_14.Updates,
                {Image1:v64Text},
                {Image2:v64Text2},
                {Image3:v64Text3}
    ) 
	}
);

 So when one of this condition is True 

    IsBlank(DataCardValue75_4.Selected.Value), Notify("Select if A been informed", NotificationType.Error, 3000),
    IsBlank(DataCardValue76_4), Notify("Select if B been informed", NotificationType.Error, 3000),
    IsBlank(DataCardValue77_4), Notify("Select if C been informed", NotificationType.Error, 3000),
    IsBlank(DataCardValue78_4), Notify("Select if D been informed", NotificationType.Error, 3000),

 your context variable

VarPatchedRecord

is not defined.

What I propose to do is to define at the start of the code the context variable VarPatchedRecord with Defaults(ListName).

UpdateContext({VarPatchedRecord:Defaults(ListName)}).

View solution in original post

1 REPLY 1
gabibalaban
Super User II
Super User II

From my understanding, this part is "false" branch of the first IF statement :

Set(
        vWait,
        true
    );
With(
    {vJSON:
        JSON(TakenPic,
            JSONFormat.IncludeBinaryData)},
      
      Set(
            v64Text,
            Substitute(vJSON,"""","")
        )
);

With(
    {vJSON2:
        JSON(TakenPic2,
            JSONFormat.IncludeBinaryData)},
      
      Set(
            v64Text2,
            Substitute(vJSON2,"""","")
        )
);

With(
    {vJSON3:
        JSON(TakenPic3,
            JSONFormat.IncludeBinaryData)},
      
      Set(
            v64Text3,
            Substitute(vJSON3,"""","")
        )
);

UpdateContext(
	{
	VarPatchedRecord:
	Patch(
		ListName, Defaults(ListName),
		Form1.Updates,
                Form1_1.Updates,
		Form1_2.Updates,
                Form1_3.Updates,
                Form1_4.Updates,
                Form1_5.Updates,
                Form1_6.Updates,
                Form1_14.Updates,
                {Image1:v64Text},
                {Image2:v64Text2},
                {Image3:v64Text3}
    ) 
	}
);

 So when one of this condition is True 

    IsBlank(DataCardValue75_4.Selected.Value), Notify("Select if A been informed", NotificationType.Error, 3000),
    IsBlank(DataCardValue76_4), Notify("Select if B been informed", NotificationType.Error, 3000),
    IsBlank(DataCardValue77_4), Notify("Select if C been informed", NotificationType.Error, 3000),
    IsBlank(DataCardValue78_4), Notify("Select if D been informed", NotificationType.Error, 3000),

 your context variable

VarPatchedRecord

is not defined.

What I propose to do is to define at the start of the code the context variable VarPatchedRecord with Defaults(ListName).

UpdateContext({VarPatchedRecord:Defaults(ListName)}).

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (56,041)