cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RoScha
Helper V
Helper V

Why does the formula do that?

Hello community,

 

I'm using this formula here when saving a record:

 

"Set(_KD_Nummer;frm_scrNeuerKunde.LastSubmit.ID);;
Patch(
P00001_KD;
LookUp(P00001_KD;ID = _KD_Nummer);
{KD_Typ: Toggle_PrFiKD_scrNeuKD.Value}
);;
NewForm(frm_scrNeuerKunde);;
Navigate(
scr_SpeichernErfolgreich_Kunde;
ScreenTransition.None
)"

 

My question is aimed at this part of the formula:
Patch(
P00001_KD;
LookUp(P00001_KD;ID = _KD_Nummer);
{KD_Typ: Toggle_PrFiKD_scrNeuKD.Value}
);;

 

The toggle button that is saved here actually only delivers a true or false as a value, but in SharePoint I have defined the column "KD_Typ", where the result true or false of the toggle button is to be saved as a number.

 

And I am currently very fascinated by the formula result that a 0 for false and a 1 for true arrives in SharePoint, but I have no idea why it happens that way.

 

Can any of you explain the "why" to me?

 

Thanks.

 

Best regards

RoScha

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@RoScha 

Please consider changing your Formula to the following:

Patch(P00001_KD;
    LookUp(P00001_KD;ID = frm_scrNeuerKunde.LastSubmit.ID);
    {KD_Typ: If(Toggle_PrFiKD_scrNeuKD.Value; 1;0)}
);;

NewForm(frm_scrNeuerKunde);;
Navigate(scr_SpeichernErfolgreich_Kunde; ScreenTransition.None)

Note, the Set was removed in this formula as you don't need to set variables in order to use them in the very next function.  If you have a need for it elsewhere, you can still refer to the LastSubmit.ID.

 

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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

3 REPLIES 3
RandyHayes
Super User III
Super User III

@RoScha 

Please consider changing your Formula to the following:

Patch(P00001_KD;
    LookUp(P00001_KD;ID = frm_scrNeuerKunde.LastSubmit.ID);
    {KD_Typ: If(Toggle_PrFiKD_scrNeuKD.Value; 1;0)}
);;

NewForm(frm_scrNeuerKunde);;
Navigate(scr_SpeichernErfolgreich_Kunde; ScreenTransition.None)

Note, the Set was removed in this formula as you don't need to set variables in order to use them in the very next function.  If you have a need for it elsewhere, you can still refer to the LastSubmit.ID.

 

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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

@RandyHayes 

Thanks for the tip. Now I also noticed that the set command was unnecessary.

But do you know why SharePoint still managed to turn a false into a 0 and a true into a 1?

 

 

Then I have a other question:
how do I get this done, if I want to post a code that is stored exactly like yours?

 

Best regards

RoScha

RandyHayes
Super User III
Super User III

@RoScha 

Yes, the default type conversion for SharePoint and PowerApps will convert to 0 or 1.  I always say to never rely on it.  I have seen more issues in play mode with assuming that type conversion will happen.  So avoid.

 

As for posting ... When you are posting a message, in the toolbar at the top, there are 3 dots

RandyHayes_0-1609963638263.png

Click on that, it will show additional options.  One of those is a "Insert Code Sample"

RandyHayes_1-1609963703596.png

Click on that and enter your formulas there.

 

_____________________________________________________________________________________
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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (20,067)