where search is the result of search.crate
# suitescript
c
where search is the result of search.crate
u
So youre saying you use the word
search
in search.create and then store the object in the same variable called
search
?
i would first try changing that
Copy code
var _search = serach().create()

_search.run().each(function(res){
    res.getValue('type').value
})
c
I added that later - at first I was doing
Copy code
getTranType(tranID).run().each(function(result){
where getTranType() returns search.create
u
gotcha,
the second thing i would do is, try this
Copy code
result.getValue('type').value
c
Copy code
log.debug({title: "tran / ID2", description:result.getValue('type').value});
nothing
u
can i see more of your code?
the whole function please
c
Copy code
function getTransactionType(transactionId) {
    return search.create({
        type: "transaction",
        filters:
            [
                ["type","anyof","SalesOrd","PurchOrd","TrnfrOrd","VendAuth","RtnAuth","WorkOrd"],
                "AND",
                ["subsidiary","anyof","1"],
                "AND",
                ["status","anyof","SalesOrd:B","PurchOrd:D","PurchOrd:E","PurchOrd:B","TrnfrOrd:D",
                    "TrnfrOrd:B","TrnfrOrd:E","VendAuth:D","VendAuth:E","VendAuth:B","WorkOrd:D",
                    "WorkOrd:B","RtnAuth:B","RtnAuth:E"],
                "AND",
                ["mainline","is","T"],
                "AND",
                ["custbody_3pl_document_number","is",transactionId]
            ],
        columns:
            [
                search.createColumn({name: "internalid", label: "Internal ID"}),
                search.createColumn({name: "trandate", label: "Date"}),
                search.createColumn({name: "tranid", label: "Document Number"}),
                search.createColumn({name: "custbody_3pl_document_number", label: "3PL Document Number"}),
                search.createColumn({name: "type", label: "Type"}),
                search.createColumn({name: "statusref", label: "Status"})
            ]
    });
}
that's the search function
Copy code
function getTransaction(transactionId) {

    getTransactionType(transactionId).run().each(function(result){

        log.debug({title:"search result", details:result});

        var tranType = result.getValue({name: 'type'});
        var internalID = result.getValue({name: 'internalid'});

        log.debug({title: "tran / ID", description:tranType+" "+internalID});


        if (tranType === "salesord") { tranType = record.Type.SALES_ORDER}
        if (tranType === "purchord") { tranType = record.Type.PURCHASE_ORDER}

        try {
            var order = record.load({
                type: tranType,
                id: internalID
            });
        } catch (e) {
            log.error({title:"couldn't find tranid: ", details: transactionId});
        }

        if (order) { return order }
    });
}
and that's the caller
u
Copy code
function getTransactionType(transactionId) {
    return search.create({
        type: "transaction",
        filters:
            [
                ["type","anyof","SalesOrd","PurchOrd","TrnfrOrd","VendAuth","RtnAuth","WorkOrd"],
                "AND",
                ["subsidiary","anyof","1"],
                "AND",
                ["status","anyof","SalesOrd:B","PurchOrd:D","PurchOrd:E","PurchOrd:B","TrnfrOrd:D",
                    "TrnfrOrd:B","TrnfrOrd:E","VendAuth:D","VendAuth:E","VendAuth:B","WorkOrd:D",
                    "WorkOrd:B","RtnAuth:B","RtnAuth:E"],
                "AND",
                ["mainline","is","T"],
                "AND",
                ["custbody_3pl_document_number","is",transactionId]
            ],
        columns:
            [
                "internalid",
                "trandate",
                "tranid",
                "custbody_3pl_document_number",
                "type",
                "statusref",
            ]
    });
}
try that
i think the label mayhave messed with it
c
that returns nothing now
u
werid, did you build the search n the UI? does it have results?
c
It was built with the ui then exported into SS2
using that chrome plugin
u
werid
c
the result variable populates so my search does work
getValue doesn't work though....
e
What do you mean "doesn't work"? Throws an error? Returns no value?
This is not valid:
Copy code
log.debug({title: "tran / ID2", description:result.getValue('type').value});
It needs to be
details
, not
description
And there won't be any
.value
on the result of a
getValue
call
c
yeah, added ,value as a suggestion from here.
I think... it could just be a logging issue as you pointed out
u
thanks Eric!
c
ha, yes. Didn't notice details instead of description. It's literally just that... THanks!
👍 1
and thank @_nikhilpalli