cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Davide_PM6176
New Member

[Forms | Variables] Get object information

Hello guys,

I'm new to PowerApps and I don't understand some things:

 

1. In my case I have a screen with two "Form" object linked to the same Sharepoint site and list (why I use two time the same Site and list? for a look problem), in one of the two form I have a "Choise field" (imported from the sharepoint connector) called "Society" and I need to use an "If" function for make the choose shorter (I need that because I want generate a custom unique ID) so I made this:

 

[OnChange] (In the Society card (SharePoint data connector) [card type: Choise field])

If(Concat(DataCardValue72.SelectedItems;Value;"") = "Society1"; UpdateContext({varSocietyShort:"S1"});"NO") 

If(Concat(DataCardValue72.SelectedItems;Value;"") = "Society2"; UpdateContext({varSocietyShort:"S2"});"NO") 

If(Concat(DataCardValue72.SelectedItems;Value;"") = "Society3"; UpdateContext({varSocietyShort:"S3"});"NO") 

 

The problem is: Im sure the "If" function work because if I take a "Label" and I put in the same level of the data card in the "Tree view" with this function:

[Text] (Label setting)

If(Concat(DataCardValue72.SelectedItems;Value;"") = "Society1";"S1";"NO") 

 

Work! But if I try to use any variable (Set or UpdateContext) the variable remain "Blank" in any case!

Another problem is if I copy the working label to the "Screen level" of the Tree View it's doesn't work!

 

There is a way to fix this?

 

Thx in advance!

Davide (or Dave)

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Davide_PM6176 

ALSO...

Make sure your form DefaultMode is set to New, or, if you really intend to have it in View or Edit, then make sure you are supplying a valid record to the Item property of the form.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

6 REPLIES 6
WarrenBelz
Super User
Super User

Hi @Davide_PM6176 ,

You might try this

With(
   {
      wVal:
	  Concat(
         DataCardValue72.SelectedItems;
         Value;""
      )
   };
   UpdateContext(
      {
         varSocietyShort:
         Switch(
            wVal;
            "Society1"; 
            "S1";
            "Society2"; 
            "S2";
            "Society3"; 
            "S3";
            "NO"
         )
      }
   )
)  

 

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.

Visit my blog Practical Power Apps

 

Hello @WarrenBelz! Thanks you for the fast reply!

I've try to put your formula on the:

 

[OnChange] (In the Society card (SharePoint data connector) [card type: Choise field])

But the variable "varSocietyShort" is still "Blank" :C

 

I do a mistake?

Thx!

RandyHayes
Super User
Super User

@Davide_PM6176 

ALSO...

Make sure your form DefaultMode is set to New, or, if you really intend to have it in View or Edit, then make sure you are supplying a valid record to the Item property of the form.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi @Davide_PM6176 ,

What are the Items of DataCardValue72 and why are your using Concat() if there is only one choice?

Hello @RandyHayes,

Thanks you for the reply, I change the state from "Edit" to "New" and now work! 

 

@RandyHayes ,

Well done - your ESP is better than mine - I have read this several times and I still don't see that as the issue from the information posted.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (3,980)