<@U5TF1GQ20> I need your help. I have two column w...
# suitescript
k
@battk I need your help. I have two column with the same name. How can i grab the value differently.
Copy code
var transactionSearchObj = search.create({
      type: "transaction",
      filters: [
        ["type", "anyof", "CashSale", "CustCred", "CustInvc", "CashRfnd"],
        "AND",
        ["subsidiary", "anyof", subsidiary],
        "AND",
        salesChannelArray,
      ],
      columns: [
        search.createColumn({
          name: "item",
          summary: "GROUP",
          label: "Item",
        }),
        search.createColumn({
          name: "formulacurrency",
          summary: "SUM",
          formula:
            "(case when ( {trandate} BETWEEN TO_DATE('" +
            r1StartDate +
            "','mm/dd/yyyy') AND  TO_DATE('" +
            r1EndDate +
            "','mm/dd/yyyy')  ) then {netamount} else 0 end)",
          label: "R1Net",
        }),
        search.createColumn({
          name: "formulanumeric",
          summary: "SUM",
          formula:
            "(case when ( {trandate} BETWEEN TO_DATE('" +
            r1StartDate +
            "','mm/dd/yyyy') AND  TO_DATE('" +
            r1EndDate +
            "','mm/dd/yyyy')  ) then {quantity} else 0 end)",
          label: "R1QtySold",
        }),
        search.createColumn({
          name: "formulacurrency",
          summary: "SUM",
          formula:
            "(case when ( {trandate} BETWEEN TO_DATE('" +
            r2StartDate +
            "','mm/dd/yyyy') AND  TO_DATE('" +
            r2EndDate +
            "','mm/dd/yyyy')  ) then {netamount} else 0 end)",
          label: "R2Net",
        }),
        search.createColumn({
          name: "formulanumeric",
          summary: "SUM",
          formula:
            "(case when ( {trandate} BETWEEN TO_DATE('" +
            r2StartDate +
            "','mm/dd/yyyy') AND  TO_DATE('" +
            r2EndDate +
            "','mm/dd/yyyy')  ) then {quantity} else 0 end)",
          label: "R2QtySold",
        }),
      ],
    });
You can see that I have two column with same name, is there a way for me to grab the second “formulanumeric” I tried
Copy code
result.getValue({
        name: "formulacurrency",
        summary: "SUM",
        label: "R1Net",
      });
b
same answer as last time
the parameters for Result.getValue should match the column, including the join and summary
although in this cast the formula too
k
Oh,,,,
Got it. thank you
b
at a certain point, it just becomes easier to store the column you create in a variable
k
Ok i’ll use
Copy code
result.columns[i]
then
thanks you for help
Hi @battk, for the client script, what function do i use for on Button press? Currently, I am using PageInit, but it is triggering my functions on page load, is there another method I can use?
b
you can choose your own function name
you use the functionName parameter to tell netsuite the name of the function
k
Got it, thank you