Fetching the subsidiary from the item record

There exists a case when fetching the subsidiary from the item record using a saved search it will populate with the default vendor subsidiary if the “Include Children” check box is checked

In such cases, we can use the saved search as below.

              var inventoryitemSearchObj = search.create({
                    type: "inventoryitem",
                    filters:
                        [
                            ["type","anyof","InvtPart"],
                            "AND",
                            ["transaction.type","anyof","ItemRcpt"],
                            "AND",
                            ["custitem29","anyof","1","13","12","5","10","9","11","8","20","6","22","7"],
                            "AND",
                            ["transaction.trandate","notbefore","daysago180"],
                            "AND",
                            [[["subsidiary","anyof","1"],"AND",["includechildren","is","T"]],"OR",[["subsidiary","anyof","9"],"AND",["includechildren","is","F"]]],
                            "AND",
                            ["internalid","anyof","199553"],
                            "AND",
                            ["isinactive","is","F"]
                        ],
                    columns:
                        [
                            search.createColumn({
                                name: "itemid",
                                summary: "GROUP",
                                sort: search.Sort.ASC,
                                label: "Name"
                            }),
                            search.createColumn({
                                name: "custitem29",
                                summary: "GROUP",
                                label: "AU Stock Status"
                            }),
                            search.createColumn({
                                name: "trandate",
                                join: "transaction",
                                summary: "MIN",
                                label: "Date"
                            }),
                            search.createColumn({
                                name: "internalid",
                                summary: "GROUP",
                                label: "Internal ID"
                            })
                        ]
                });
                var searchResultCount = inventoryitemSearchObj.runPaged().count;
                log.debug("inventoryitemSearchObj result count",searchResultCount);

Leave a comment

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