Saved Search Function to check whether items exist with similar drawings name in file cabinet

  /**
           * Saved search function to check whether items exist with similar drawings name
           * @param drawingPdfName{string}- drawings name
           * @returns itemsArray - array containing the items with similar drawings name
           */
        function searchItemsWithPdfName(drawingPdfName) {
            try {
                let itemsArray = [];
                let itemSearchObj = search.create({
                    type: "item",
                    filters:
                        [
                            ["type", "anyof", "Assembly"],
                            "AND",
                            ["name", "contains", drawingPdfName],
                            "AND",
                            ["custitem_jj_is_attached_gtilc_397", "is", "F"],
                            "AND",
                            ["isinactive", "is", "F"]

                        ],
                    columns:
                        [
                            search.createColumn({ name: "internalid", label: "Internal ID" })
                        ]
                });
                itemSearchObj.run().each(function (result) {
                    let itemId = result.getValue({
                        name: "internalid",
                        label: "Internal ID"
                    })
                    itemsArray.push(itemId);
                    return true;
                });
                return itemsArray;

            } catch (error) {
                log.debug("error @searchItemsWithPdfName", error);
                return [];
            }
        }

Leave a comment

Your email address will not be published. Required fields are marked *