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

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
Highlighted
Advocate V
Advocate V

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

View solution in original post

Highlighted
Community Support
Community Support

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.

View solution in original post

8 REPLIES 8
Highlighted
Advocate V
Advocate V

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.
Highlighted
Advocate V
Advocate V

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

View solution in original post

Highlighted
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


@iAm_ManCat

Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Highlighted
Community Support
Community Support

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.

View solution in original post

Highlighted
Helper II
Helper II

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

Highlighted
Super User
Super User

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

Please mark one of the answers as the Solution 🙂


@iAm_ManCat

Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Highlighted
New Member

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
New Member

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

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,890)