cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mikiepat12
Level: Power Up

How do i set a datacard value based on Mode

Hi,

 

I'm struggling with this at the moment, i want to alternatively show numbers entered into 2 datacards ('LinesTotalNew' & 'LinesTotalEdit') into another datacard based on whether the form is in New or Edit mode i.e. show 'LineTotalsNew' number when in new form mode and 'LineTotalsEdit' when in edit form mode. The app writes data back to a Sharepoint list; i want to take the values from these datacardvalues ('LinesTotalNew' & 'LinesTotalEdit') to update the new datacardvalue which will get written back to Sharepoint. 

 

The Default formula i'm using at the moment is: If(EditForm1.Mode = FormMode.New, !IsBlank(LinesTotalNew),EditForm1.Mode = FormMode.Edit,  !IsBlank(LinesTotalEdit), Parent.Default)

 

I get no errors using this formula but no value is showing in the DataCardValue text box. When i just set the Default value to either of these datacard names it returns a value. Anyone know why this is not working or can suggest an alternative?

 

Any help much appreciated

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
gokello
Level 8

Re: How do i set a datacard value based on Mode

I reviewed this again.. This worked for me: If(Form1.Mode = FormMode.New,TextInput1, (If(Form1.Mode = FormMode.Edit,TextInput2))) Where FormName = "Form1" and.. Replace TextInput1 with contents of LinesTotalNew and TextInput2 with the contents of LinesTotalEdit
Community Support Team
Community Support Team

Re: How do i set a datacard value based on Mode

Hi @mikiepat12 ,

 

I think that there’s something wrong in your formula .

!Isblank(LinesTotalEdit) and !Isblank(LinesTotalNew) return trueor falsevalue.  

 

You can follow this solution.

11.PNG

 

Set Default property of DataCardvalue8 :

If(EditForm1.Mode=FormMode.New&&Not(IsBlank(DataCardValue6)),DataCardValue6.Text,EditForm1.Mode =FormMode.Edit&&Not(IsBlank(DataCardValue7)),DataCardValue7.Text,Parent.Default)

Regards,

Eason

Community Support Team _ Eason YU
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
8 REPLIES 8
gokello
Level 8

Re: How do i set a datacard value based on Mode

How does the form transition from New to Edit modes? Is this done via an action button? If so that we could pass a variable alongside the Form Mode and use the value of the variable to determine whether to display 'LinesTotalNew' or 'LinesTotalEdit' in the third datacard.
gokello
Level 8

Re: How do i set a datacard value based on Mode

I reviewed this again.. This worked for me: If(Form1.Mode = FormMode.New,TextInput1, (If(Form1.Mode = FormMode.Edit,TextInput2))) Where FormName = "Form1" and.. Replace TextInput1 with contents of LinesTotalNew and TextInput2 with the contents of LinesTotalEdit
Super User
Super User

Re: How do i set a datacard value based on Mode

Hi,

 

Yes I think I can answer this - Your formula is writing a default value of !IsBlank(LinesTotalNew) or !IsBlank(LinesTotalEdit)... which are function calls, so your default value will check if they are blank and then send back either true or false, not the actual value.

 

So I would think you want it to be:

If(

   EditForm1.Mode = FormMode.New,

      LinesTotalNew,

   EditForm1.Mode = FormMode.Edit,

      LinesTotalEdit,

   Parent.Default
)

 

Cheers,

@iAm_ManCat



My loving and understanding partner gives the best advice on fixing errors: "Just type in some different things".

Don't forget to Mark as Solution and Thumbs Up those who deserve it!
Community Support Team
Community Support Team

Re: How do i set a datacard value based on Mode

Hi @mikiepat12 ,

 

I think that there’s something wrong in your formula .

!Isblank(LinesTotalEdit) and !Isblank(LinesTotalNew) return trueor falsevalue.  

 

You can follow this solution.

11.PNG

 

Set Default property of DataCardvalue8 :

If(EditForm1.Mode=FormMode.New&&Not(IsBlank(DataCardValue6)),DataCardValue6.Text,EditForm1.Mode =FormMode.Edit&&Not(IsBlank(DataCardValue7)),DataCardValue7.Text,Parent.Default)

Regards,

Eason

Community Support Team _ Eason YU
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
mikiepat
Level: Powered On

Re: How do i set a datacard value based on Mode

Brilliant that works. I'm a newbie to Powerapps so that had me stumped for a few hours. Many thanks goKello and I appreciate the prompt response!

 

Mike

Super User
Super User

Re: How do i set a datacard value based on Mode

Please mark one of the answers as the Solution Smiley Happy



My loving and understanding partner gives the best advice on fixing errors: "Just type in some different things".

Don't forget to Mark as Solution and Thumbs Up those who deserve it!
mikiepat12
Level: Power Up

Re: How do i set a datacard value based on Mode

Hi iam_ManCat,

 

I tried that formula before and doesn't work although can't see anthing wrong with the logic - cheers fro reply

 

Mike

Highlighted
mikiepat12
Level: Power Up

Re: How do i set a datacard value based on Mode

Hi v-sheyu-msft,

 

Thanks for reply - your formula works as well and may be a good solution for what i'm looking for i.e. to return the value from the parent record when those other values are blank

 

thanks again for your response,

 

Mike