manueltoniato's Profile
Rookie
7
Points

Questions
1

Answers
2

  • Rookie Asked on June 10, 2020 in SuiteScript.

    I cannot find a solution in a direct way but I solved in another way.
    I didn’t add the fields as joined fields but as formulatext. The unique identifier after formulatext permits to access each field separately.

    var filters= [];
    filters.push(new nlobjSearchFilter("internalid",null,"is", 40556971));
    filters.push(new nlobjSearchFilter("accounttype",null,"anyof","@NONE@"));
    var columns=[];
    column=new nlobjSearchColumn("formulatext_externalid");
    column.setFormula("{item.externalid}");
    columns.push(column);
    column=new nlobjSearchColumn("formulatext_color");
    column.setFormula("{item.custitem_flb_santoni_colore}");
    columns.push(column);
    column=new nlobjSearchColumn("formulatext_size");
    column.setFormula("{item.custitem_flb_santoni_taglia}");
    columns.push(column);
    columns.push(new nlobjSearchColumn("accounttype"));
    columns.push(new nlobjSearchColumn("quantity"));
    var searchresult = nlapiSearchRecord("transaction", null, filters, columns );
    

    • 2079 views
    • 2 answers
    • 0 votes
  • I tried to use formulatext_1 but it doesn’t work.
    Meanwhile I received an answer by Scott on slack channel.
    In order to distinguish different formulas in template we can add a unique id after formulatext.
    For example one can add “formulatext_color” and then retrieve it from template with ${formulatext_color}.
    I think this is what Netsuite do on saved searches created on UI.
    With this hint my code becomes:

    
    var filters= [];
    
    filters.push(new nlobjSearchFilter("internalid",null,"is", 40556971));
    
    filters.push(new nlobjSearchFilter("mainline",null,"is", "F"));
    
    filters.push(new nlobjSearchFilter("shipping",null,"is", "F"));
    
    filters.push(new nlobjSearchFilter("taxline",null,"is", "F"));
    
    filters.push(new nlobjSearchFilter("accounttype",null,"anyof","COGS"));
    
    var columns=[];
    
    column=new nlobjSearchColumn("formulatext_externalid");
    
    column.setFormula("{item.externalid}");
    
    columns.push(column);
    
    column=new nlobjSearchColumn("formulatext_color");
    
    column.setFormula("{item.custitem_flb_santoni_colore}");
    
    columns.push(column);
    
    column=new nlobjSearchColumn("formulatext_size");
    
    column.setFormula("{item.custitem_flb_santoni_taglia}");
    
    columns.push(column);
    
    columns.push(new nlobjSearchColumn("accounttype"));
    
    columns.push(new nlobjSearchColumn("quantity"));
    
    var searchresult = nlapiSearchRecord("transaction", null, filters, columns );
    
    

    I don’t understand if it is an “official” solution or if it is a workaround: anyway by now it works very well.

    • 2935 views
    • 2 answers
    • 0 votes