Hi,
I need to throw an error if certain values are not true. The values are in a different list so I am doing the code like this
fd.spBeforeSave(function ()
{
var id = fd.field('ID').value;
var length = 0;
var string = "Bid_x0020_Line_x0020_ID eq " + id + " and Submit ne false";
sp.web.lists.getByTitle("Bid Type Lines").items.filter(string).get().then(function(items)
{
length = items.length;
if (length == 2)
{
fd.field('Modify').value = false;
throw Error('Technical and Commercial both are required.');
}
});
});
The code is working fine and is returning the count/values which I need but its not changing the value of field Modify and throw Error is not working as well. Is there any way to achieve this.
My condition is if length equal to 0 or 1 then throw error but as you can see in my screenshot its returning length 2 but still the error is showing and I cant submit the form.
Thank you for your help. This code works fine but this doesnt refresh since the pnp code is on spRendered it works when I open the form. After opening the form If I receive the error and I fixed by submitting all documents which is a list or library control the length variable still contains value 1 .
I rearranged the code on submit button like this.
var length = 0;
var string = "Bid_x0020_Line_x0020_ID eq " + id + " and Submit ne false";
Yes I am using the list or library control to display related items.
Add validation based on list or library control means add event function on list or library control like this
fd.control('SPDataTable0').$on('change', function(changeData)
or
fdfd.control('SPDataTable0').validator?
This doesnt work as well. However I did a work around. I am using pnp.items.getById(1).update function to update. The only thing is I need an ID for this to work and I can only get the id on fd.spSaved. This is my code.
fd.spSaved(function (result)
{
var id = result.Id;
generateReferenceNo(id);
});
function generateReferenceNo(id)
{
var number = 0;
var lastNo = '';
var refNo = '';
var bidding = pnp.sp.web.lists.getByTitle("Bidding");
bidding.items.getById(id).update(
{
Reference_x0020_No: refNo,
NoSeries: true
});
}
I would like to know is it possible to create a record when I fill my title field. Actually I am coming from Microsoft Dynamics NAV background and I am trying to make it in same way.
If I put a value in title field is it possible to insert the record and create the ID so that I can use that.
I tried using the change event of field title and put fd.save() there but that closes the form as well.
My requirement is to generate an auto generated number for each record. Demo