So i have a datacard that has a combobox with lookUp field(foreign key). I set the Lookup field with required in Sharepoint and add true to the required properties and it still ignore the validation. so i tried to see what is inside the datacard but i can't find the value of the record of Update. Should i simply make my own validation while the combobox is blank, i disable the submit button or use the submit form validation?
Solved! Go to Solution.
This is because the Valid property of the Datacard will be true if something is in the Update property. You are providing a record for your Update property...thus it will not be blank - even if what is in it is blank.
Change your Update property to the following:
If(IsBlank(DataCardValue2.Selected), Blank(),
{Id: DataCardValue2.Selected.ID,
Value: DataCardValue2.Selected.Value //this should not be ID
}
)
Also, the Value of the Lookup column is usually based on a particular column from the foreign list. You should not be providing ID for both of them. Please review your lookup column definition to see what column value it wants.
Also, this can be highly simplified if your DataCardValue2 Items property is based on the Choices function on that Lookup column. The Choices function will return a table with an Id and Value column from the foreign list that is all ready to use. Then your Update property simply becomes : DataCardValue2.Selected If nothing is selected, then the datacard (if required - which it is) will be invalid.
I hope this is helpful for you.
Hi @ale100 ,
Select the Datacard on the form and go to advanced properties of that and set the required property to True. You made the field required at datasource level, not at the form level which is what causing the issue for you.
Note: you will see this requred property at datacard level not at the combobox level. so set this at datacard level.
Hi @KrishnaV
It is already in required, there even the star that show the field is required, but when i tried to submit, no error pop ups. If i complete the form with data, it will create the item without the foreign key.
This is because the Valid property of the Datacard will be true if something is in the Update property. You are providing a record for your Update property...thus it will not be blank - even if what is in it is blank.
Change your Update property to the following:
If(IsBlank(DataCardValue2.Selected), Blank(),
{Id: DataCardValue2.Selected.ID,
Value: DataCardValue2.Selected.Value //this should not be ID
}
)
Also, the Value of the Lookup column is usually based on a particular column from the foreign list. You should not be providing ID for both of them. Please review your lookup column definition to see what column value it wants.
Also, this can be highly simplified if your DataCardValue2 Items property is based on the Choices function on that Lookup column. The Choices function will return a table with an Id and Value column from the foreign list that is all ready to use. Then your Update property simply becomes : DataCardValue2.Selected If nothing is selected, then the datacard (if required - which it is) will be invalid.
I hope this is helpful for you.
hi @RandyHayes !
I test something, It does give me true to this formula
IsBlank(DataCardValue2.Selected)
Also for the value of the lookup, i can't really change this. because it refer the ID in a joint table that rely 2 lists. I know it can't do many-to-many-relationship, but i can't use sql or cds.i'll try to do a workaround with the few days lefts.
The update formula should give you what you need.
As for the lookup - you are not changing anything about the column in your list, you are just needing to provide the proper values in your formula.
If you look at the definition of the lookup column in your list, it will show "In this column:" and will show what the Value should be from.
The below shows a definition of a lookup and in this you can see that the lookup wants its Value to be the Title from the foreign list.
So, to update this Lookup, I would provide the ID of the foreign record for the Id and the Title value for the Value.
the definition of the lookup column where is that? all i have is the parameters of the column, but i get it, i shouldn't use the id like it did, in the lookup column. My issue is the ProblemDetailId, this lookup is the ID of a record where an horse and an injuries is. Could i done better yes, Can i do it now. not if i want to rework all my application
Again if i knew how to do it way earlier i would.
Go into your list in SharePoint, then go to the List Settings for that list, then click on that lookup column in your list of columns. It will then show you the definition for the column.
Looking at my prior post, it was supposed to have an image in it...not sure where it went.
I will try again here below:
User | Count |
---|---|
247 | |
105 | |
82 | |
50 | |
43 |