cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Masoud9
Frequent Visitor

New form with preset fields

Hi!

 

I have an App based on a SharePoint list. The app is for problem reporting, so each time it is used a New Form is opened to be filled with the information concerning the problem. When it comes to the form, I want to have some fields filled by the users (such as the problem description, the actions taken etc.) but, in order to save time, I would like to have some fields automatically filled depending on some conditions:

 

- Date: I want this field filled with Today Date

- User ID: I want to have here the user name automatically

- Improvement Idea: I have a button which sets a value (If you click on it the Value is "Idea" if not is "NO") I want this SP field to be filled with wichever the selected value is

 

I've tried modifying the fields "Default" and "Update" of my DataCards but without success. Could someone help me please? Thank you very much!

 

Masoud9

1 ACCEPTED SOLUTION

Accepted Solutions

@Masoud9 
This is the code you should use in the Update field assuming UserID is a Choices field.  The UserID must be in the list of valid Choices to see the change successfully update in SharePoint.

 

DataCardValue1.Selected.Value

 

Can you take a screenshot of your app with the Datepicker control highlighted?  I want to know: is this datepicker control inside of an Edit Form?

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up." 

View solution in original post

12 REPLIES 12
eka24
Super User III
Super User III

Try this:
Date : Today()

UserID: User().FullName

ImprovementIdea: MyIdea

 

For the Improvement idea, consider:

OnVisible of the Screen Put:
UpdateContext( { MyIdea: “No”} )

 

Also put this on  OnSelect of a Button:

UpdateContext( { MyIdea: “Idea”} )

So whenever the button is clicked, the value changes from “No” to “Idea”

Then on default of the textbox, put the variable: MyIdea

 

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

mdevaney
Super User III
Super User III

@Masoud9 

Set the Default property of each control to Parent.Default

 

Then put this code in the Default property of the card containing the control.

 

Date:

Today()

 

UserID:

User().Email

 

Improvement Idea:

your_variable_name

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Eelman
Super User
Super User

@Masoud9 

Can you share what you've tried already?

 

Usually, something like this works

Default = If( Form1.Mode = FormMode.New, Today(), Parent.Default)

Masoud9
Frequent Visitor

@Eelman @mdevaney @eka24 

 

That's more or less what I've tried but I get an error with that.

The "Date" DataCard doesn't give me error but it's not working (the date is not submitted to the SP list).

The other two the messages I receive are:

 

Expected Record Value

The property of this control expects Record values. The rule produces Text values which are incompatible.

 

Attached are the screenshots for the three issues.

The User ID field and the Impr. Idea are "choice fields" in SP, Could that be the problem?

@Masoud9 

Can you please share what's in the Update property of the Card for Date?  This is what controls how the new value is inserted back into SharePoint.

For UserID you can try this code assuming a UserID is the current user's email.  It must already be within the list to appear. 

{Value: User().Email}

 

Same idea for the other one.  We have to do it this weird way because you are using a Choices field which expects a record value instead of text. 

{Value: your_variable_name}

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Masoud9
Frequent Visitor

Hi @mdevaney ,

 

It's almost solved, the problem is related to the Update value, with the formulas you have proposed I can obtain the user ID without error but it is not updated in SP when the form is submitted.

 

Currently what I have in this Update field is:

 

DataCardValue1.Selected

 

But as it is a fixed value it doesn't seems to work, Which formula can I use to make it work?

On the other hand, concerning the Date field, I don't have the Update field available, but the problem is similar, it doesn't update the SP. Any possible solution for this?

 

Thank you very much!

@Masoud9 
This is the code you should use in the Update field assuming UserID is a Choices field.  The UserID must be in the list of valid Choices to see the change successfully update in SharePoint.

 

DataCardValue1.Selected.Value

 

Can you take a screenshot of your app with the Datepicker control highlighted?  I want to know: is this datepicker control inside of an Edit Form?

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up." 

View solution in original post

@Masoud9 

What field types are Date, User and ImprovementIdea in SharePoint? 

 

These errors sound to me like there are data mismatches. At a guess, I'd say

 

Date  = Date/Time where DateandTime are required

User = is a Person or LookUp column, and

ImprovementIdea = is a LookUp or Choice column

 

Could you please confirm the column types in your List.

Masoud9
Frequent Visitor

Thank you very much @mdevaney and @Eelman, finally I've solved the problem.

 

In the case of the user ID it was that I had to select one available option among the choices of my SP column. When I did that, it worked.

In the case of the date I just put DataCardValue.SelectedDate to fix it.

 

Now it is working perfectly. Thanks for your suport!

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

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

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,897)