cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

how to manage variable value to show/hide field

Hello guys,
I'm facing this issue I don't really understand what's happening.

I have a form and in one section I try to shows controls based on the selection of one button. It works when I create an item, then when I try to update, it's like all those variables are setting and it shows me all the hidden controls. But I need to keep the same state as it was. Any help ? 

cahobaut_0-1622444734808.png

in this screenshot I've created an item and I've fill the 4 line by showing the controls with the + button. But when I try to edit all the rows appear as if it was clicked. I really don't understand. Thanks in advance

9 REPLIES 9
WarrenBelz
Super User
Super User

@Anonymous ,

Can you please share some code here (in Text) - I cannot see your model or what exactly you are trying to do.

The Items of the Gallery as well as the code on the plus and minus buttons would be a good start. Also the Visible and DefaultMode on the controls you are expecting to behave differently.

Anonymous
Not applicable

What I wanted to achieve is to let the user add more value for theses 3 fields. I've started with lookup but hit the trigger limit from sp. Then I've deceided to use text field then get the value inside combo box to populate this text field. It works as expected.
Here are the code for the   - (minus): 

 

And(Set(vAddRow2, false),Set(vAddBtn, true),Set(vAddBtn2,false),Reset(ComboBox2),Reset(ComboBox2_1),Reset(DataCardValue7))

 

 

+ (plus): 

 

Set(vAddRow3, true);Set(vAddBtn2,false);Set(vAddBtn3, true)

 

 

vAddRowX is use to show the controls on a specific row

 

The visible property for the button is : 

 

If(varFormMode = FormMode.View,false,vAddRow2)

 

 

I've try to set these variaable at a top level:

Sharepoint Integration onNew: 

 

NewForm(formGI); Set(varFormMode, FormMode.New);Navigate(ScreenGeneralInformation, ScreenTransition.None);And(Set(vAddRow2, false),Set(vAddRow3, false), Set(vAddRow4, false),Set(vAddRow5, false), Set(vAddRow6, false), Set(vAddRow7, false), Set(vAddRow8, false), Set(vAddRow9, false), Set(vAddRow10, false),Set(vAddBtn, true), Set(vAddBtn2, false), Set(vAddBtn3, false), Set(vAddBtn4, false), Set(vAddBtn5, false), Set(vAddBtn6, false), Set(vAddBtn7, false), Set(vAddBtn8, false), Set(vAddBtn9, false), Set(vAddBtn10, false));

 

 

onView:

 

ViewForm(formGI); Set(varFormMode, FormMode.View);Navigate(ScreenGeneralInformation, ScreenTransition.None);
And(Set(vAddRow2, vAddRow2),Set(vAddRow3, vAddRow3), Set(vAddRow4, vAddRow4),Set(vAddRow5, vAddRow5), Set(vAddRow6, vAddRow6), Set(vAddRow7, vAddRow7), Set(vAddRow8, vAddRow8), Set(vAddRow9, vAddRow9), Set(vAddRow10, vAddRow10),Set(vAddBtn, vAddBtn), Set(vAddBtn2, vAddBtn2), Set(vAddBtn3, vAddBtn3), Set(vAddBtn4, vAddBtn4), Set(vAddBtn5, vAddBtn5), Set(vAddBtn6, vAddBtn6), Set(vAddBtn7, vAddBtn7), Set(vAddBtn8, vAddBtn8), Set(vAddBtn9, vAddBtn9), Set(vAddBtn10, vAddBtn10));

 

onEdit:

 

EditForm(formGI); Set(varFormMode, FormMode.Edit);Navigate(ScreenGeneralInformation, ScreenTransition.None);
And(Set(vAddRow2, vAddRow2),Set(vAddRow3, vAddRow3), Set(vAddRow4, vAddRow4),Set(vAddRow5, vAddRow5), Set(vAddRow6, vAddRow6), Set(vAddRow7, vAddRow7), Set(vAddRow8, vAddRow8), Set(vAddRow9, vAddRow9), Set(vAddRow10, vAddRow10),Set(vAddBtn, vAddBtn), Set(vAddBtn2, vAddBtn2), Set(vAddBtn3, vAddBtn3), Set(vAddBtn4, vAddBtn4), Set(vAddBtn5, vAddBtn5), Set(vAddBtn6, vAddBtn6), Set(vAddBtn7, vAddBtn7), Set(vAddBtn8, vAddBtn8), Set(vAddBtn9, vAddBtn9), Set(vAddBtn10, vAddBtn10));

 

.

The issue occur when I try to update for the second time it seems like all my variable are set to true.
I've added a label on top of my scrren to view the vAddRow2 value. It's strange because it show false but I still can see the control 😕

 

cahobaut_0-1622447415182.png

the vAddRow2 value is false but we can see the second row of controls on which each element has the visible property set to vAddRow2

@Anonymous ,

I have to ask one more question here - did you write this code, or are you trying to fix someone else's work?

I must admit I expected something fairly simple here.

 

Anonymous
Not applicable

I wrote it. But yes, I think the error come from the logic. It's (+) supposed to hide the button the display the next line with the next button. Or hide the row (-) with the button, reset the controls and show the previous button. I'll like a simple solution 

Thanks @Anonymous ,

Knowing that, can you please explain in a few bullet points what you are expecting to happen, what code is running when you expect it to and what happens instead.

I can tell you now that SharePoint Integrated forms do not always do exactly what you expect when you start modifying the built-in functions (OnNew, OnView, OnEdit etc).  

Anonymous
Not applicable

I have this section where I want to add or hide controls based on theses buttons:

-I want to show controls when clicking on the (+) and hide them on the (-).

-I want to keep these fields in the same state in all modes. And hide just the button in view mode.

 

Currently I can't get them in the same time when I update the form. They're all appearing.

 

In the first line the (+) button is as following onSelect : 

Set(vAddRow2, true);Set(vAddBtn, false);Set(vAddBtn2,true)

this code shows the next set of controls then hide the button of the previous line. In the next line all the item have the Visible property set to vAddRow2.

It's the same for the 10 rows that I have.

 

Finally I just manage theses variable into the OnNew property:

NewForm(formGI); Set(varFormMode, FormMode.New);Navigate(ScreenGeneralInformation, ScreenTransition.None);And(Set(vAddRow2, false),Set(vAddRow3, false), Set(vAddRow4, false),Set(vAddRow5, false), Set(vAddRow6, false), Set(vAddRow7, false), Set(vAddRow8, false), Set(vAddRow9, false), Set(vAddRow10, false),Set(vAddBtn, true), Set(vAddBtn2, false), Set(vAddBtn3, false), Set(vAddBtn4, false), Set(vAddBtn5, false), Set(vAddBtn6, false), Set(vAddBtn7, false), Set(vAddBtn8, false), Set(vAddBtn9, false), Set(vAddBtn10, false));

to set them only when a new form is raised. (Hoping that it works when we're in a different mode^^).

I've set the onVisible property of my screen as following:

And(Set(vAddRow2, vAddRow2),Set(vAddRow3, vAddRow3), Set(vAddRow4, vAddRow4),Set(vAddRow5, vAddRow5), Set(vAddRow6, vAddRow6), Set(vAddRow7, vAddRow7), Set(vAddRow8, vAddRow8), Set(vAddRow9, vAddRow9), Set(vAddRow10, vAddRow10),Set(vAddBtn, vAddBtn), Set(vAddBtn, vAddBtn),Set(vAddBtn2, vAddBtn2), Set(vAddBtn3, vAddBtn3), Set(vAddBtn4, vAddBtn4), Set(vAddBtn5, vAddBtn5), Set(vAddBtn6, vAddBtn6), Set(vAddBtn7, vAddBtn7), Set(vAddBtn8, vAddBtn8), Set(vAddBtn9, vAddBtn9), Set(vAddBtn10, vAddBtn10));

 

Hope that it's enough clear. Do not hesitate to ask for more information 😕 Thanks

Hi @Anonymous ,

I must apologize here, but I cannot possibly get my mind around the complexity of what you are doing without actually having the app. I will however suggest an alternative to all of that.

If you simply set a Variable on the OnSelect of your buttons to indicate you have selected them, you can test directly the mode of the Form (forget about the Integration code). So on the OnSelect of the Plus button

UpdateContext(
   {
      varPlus:true,
      varMinus:false
   }
)

the opposite on the minus button

UpdateContext(
   {
      varPlus:false,
      varMinus:true
   }
)

Now on each control Visible, simply test for two things (you just need two statements)

FormName.Mode = FormMode.xxxx &&
varPlus  //or varMinus

If you want to only affect the selected item, add this (example)

FormName.Mode = FormMode.Edit && varPlus && ThisItem.IsSelected

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

Anonymous
Not applicable

I've try your solution but it's the same. When getting the form in view mode it shows me all the rows as if their visible property was to true. I've one variable for each row and the variable for a row is set at the previous line. I don't know how it show me all the controls even if I've not clicked on the Plus of the previous line. To show them I don't need to verify the form mode it's more for the button but it's ok.
I cannot get ThisItem.IsSelected too

@Anonymous .

That really does not help me.

You need to explain what code you have tried (please keep to only the relevant parts) and exactly what you want to display and when. You can control the visibility of any control by simply testing all the elements that need to be present (or not). Also what do you mean by you cannot get ThisItem.IsSelected?

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,619)