cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KarlAddi
Helper I
Helper I

An entry is required or has an invalid value error

So I am having trouble with the above error. I have a form that was working as expected but after an hour or so it started giving me that error. 

 

I've read through lots of solved solutions for the issue but none of them seem to solve mine. 

 

I have an edit form that the user inputs part information and based on the "Supplier Pn", if the item already exists in the sharepoint list, it will just add the "Quantity" to the existing part and if the "Supplier Pn" doesn't exist, it submits the form as a new item. 

 

The issue comes when I try to add a new part that is not already on the sharepoint list. But it will work when the "Supplier" part number exists. 

 

The OnSubmit code for the "Add Items" button on the edit form is as follows :

UpdateContext({locShowSpinner1: true});

ClearCollect(
    GetExisting,
    LookUp(
        'Fan-Attic',
        field_Supplier_x0020_Pn = SupplierDataCard4.Text
    )
);
Set(
    CurrentQty,
    If(
        IsEmpty(GetExisting) || IsBlank(GetExisting),
        0,
        Value(First(GetExisting).field_Qty)
    )
);
Set(varSuccess,Patch(
    'Fan-Attic',
    If(
        !IsBlank(GetExisting),
        First(GetExisting)
    ),
    {
        field_Supplier_x0020_Pn: SupplierDataCard4.Text,
        field_Qty:(IfError(Value(QTYDataCard4.Text), Blank())) + CurrentQty
    } 
);
If(!IsBlank(varSuccess), Navigate(SuccessAdded, Fade) && ResetForm(Form3)
));


If(
    IsEmpty(GetExisting) || IsBlank(GetExisting),
    SubmitForm(Form3), Navigate('Add Items_1') && Notify("Required Item Missing", NotificationType.Error)
);


UpdateContext({locShowSpinner1: false});

 

So far I've tried

- I've set the Default property of all data cards to Blank() and this did nothing, these have since been set back to "Parent.Default"

- Made all Required properties of the data cards set to false, this didn't work

- Made sure that the sharepoint list settings don't have the columns set to required

- Turned off the Upcoming feature "Delayed Load"

 

So I feel like I've exhausted all options and it's not ideal as this app will be shared a large group of people and for it to be working one minute and not another is very worrying.

 

Hopefully someone can help

 

3 REPLIES 3
WarrenBelz
Super User
Super User

Hi @KarlAddi ,

I do not fully understand your model, but have a look at the basic structure below (this is guidance only)

UpdateContext({locShowSpinner1: true});
With(
   {
      wExisting:
      LookUp(
         'Fan-Attic',
         field_Supplier_x0020_Pn = SupplierDataCard4.Text
      )
   }
   Set(
      CurrentQty,
      If(
         IsBlank(QTYDataCard4.Text),
         0,
         Value(QTYDataCard4.Text)
      ) + 
      If(
         IsBlank(wExisting.field_Qty),
         0,
         wExisting.field_Qty
      )
   )
);
Set(
   varSuccess,
   Patch(
      'Fan-Attic',
      If(
         CurrentQty = 0,
         Defaults('Fan-Attic'),   //this patches new record
         {ID:GetExisting.ID},     //this updates existing record
      ),
      {
         field_Supplier_x0020_Pn: SupplierDataCard4.Text,
         field_Qty:CurrentQty
      } 
   )
);
If(
   !IsBlank(varSuccess), 
   Navigate(
      SuccessAdded, 
      Fade
   ); 
   ResetForm(Form3)
);

// all the below may be redundant
If(
   IsBlank(GetExisting.field_Qty),
   SubmitForm(Form3), see above for new item
   Navigate('Add Items_1');
   Notify(
      "Required Item Missing", 
      NotificationType.Error
   )
);
UpdateContext({locShowSpinner1: false});
WarrenBelz
Super User
Super User

Hi @KarlAddi ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Hey Warren, 

 

So I'm not 100% sure what I changed for the issue to resolve itself but I've made some slight changes to the code and the issue seems to have stopped. The updated code is as follows:

UpdateContext({locShowSpinner1: true});

ClearCollect(
    GetExisting,
    LookUp(
        'Fan-Attic',
        field_Supplier_x0020_Pn = SupplierDataCard4.Text
    )
);
Set(
    CurrentQty,
    If(
        IsEmpty(GetExisting) || IsBlank(GetExisting),
        0,
        Value(First(GetExisting).field_Qty)
    )
);
Set(
    varSuccess,
    Patch(
        'Fan-Attic',
        If(
            !IsBlank(GetExisting),
            First(GetExisting)
        ),
        {
            field_Supplier_x0020_Pn: SupplierDataCard4.Text,
            field_Qty: Value(QTYDataCard4.Text) + CurrentQty
        }
    );
    If(
        !IsBlank(varSuccess),
        Navigate(
            SuccessAdded,
            Fade
        ), Navigate(SuccessAdded,Fade)
    )
);


If(
    IsEmpty(GetExisting) || IsBlank(GetExisting),
    SubmitForm(Form3)
);

UpdateContext({locShowSpinner1: false});

I'm also aware that there is no error prevention added into the code but this doesn't really matter as the submit button for the form has been set up to stay inactive until all fields have been filled in and these field have been set so the user can only input numbers in the number fields and text in the text field etc.. 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,435)