Change column after filtering list and library control

good day,
In button i want to filter by caml list library control and then change the column status if it is -new - change it to in progress.
i make only filter..

var filter = "<And>"
//add existing filter value
filter += fd.control('SPDataTable1').filter;
//add your own filtering conditions
filter +=  "<Eq><FieldRef Name='Status'/><Value Type='Text'>New</Value></Eq>";
filter += "</And>"
//filter list or library control   
fd.control('SPDataTable1').filter = filter;

function SaveOrClose() {
//change Status to in Progress
if (fd.control('SPDataTable1').widget.dataItems().length > 0) {
    fd.spClosed(function() {


Dear @ixxxl,
What is it exactly that you want to achieve? Do you want a button that will go through all items in List or Library, and change their status to something else?

The issue here is that if List or Library has more than 1 page, you cannot retrieve all the items directly from it - need to send a pnpjs request to the source list and filter them to only the ones visible on the form.

Are you working from New or Edit/Display form? Does List or Library have a parent lookup field filled in with parent ID?

Yes, i want a button that will go through all items in List or Library, and change their status to something else.
It is Edit form, Yes list and library have a lookup with parent ID.
I think i will have not so many items...

Dear @ixxxl,
You can try the following code, it should do the trick:

var listName = "Status List";
var list = pnp.sp.web.lists.getByTitle(listName);
    var id = fd.itemId;
    list.items.filter("Status eq 'New' and Parent/Id eq '" + id + "'").get().then(function(items){
      var batch = pnp.sp.web.createBatch();
      for(var i = 0; i < items.length; i++){
        //specify which fields to update and how
            Status: 'In-Progress'
        }, "*", entityTypeFullName);

1 Like

i tryed, but have an error

P.S i just found a mistake.
Instead of Parent/id - a forgot to put my field name - Lookup/id
Now it works!!! Thank you so much

1 Like