i send an array from UE script to CS script. in CS...
# suitescript
v
i send an array from UE script to CS script. in CS, only the first value is taken, remaining are not taken. how can it be solved? can anyone please help?
b
log the string you are using for the functionName
v
sorry i dont get it. could you please explain?
ah yeah i got it.
i logged. in UE its an array with two values. but in CS, its only the first value
b
functionName is a string parameter, whatever you pass to it is going to be a string, an array is not a valid choice nor is it what you are doing
you need to figure out what you are passing to it so you can understand whats being run in the browser
alternatively you can also inspect the button in your browser to see what the onClick function looks like, though that will be uglier
v
i am passing two internal ids.
how to inspect
v
Thank you @battk
this is what i am getting
<input type="button" style="" class="rndbuttoninpt bntBgT" value="Remind Treasury" id="custpage_remindtreasury" name="custpage_remindtreasury" onclick="var rConfig = JSON.parse( '{}' ) ; rConfig['context'] = '/SuiteScripts/Dynappco/userevent/CMB_cs_pfa_functions'; var entryPointRequire = require.config(rConfig); entryPointRequire(['/SuiteScripts/Dynappco/userevent/CMB_cs_pfa_functions'], function(mod){ try{ if (!!window) { var origScriptIdForLogging = window.NLScriptIdForLogging; var origDeploymentIdForLogging = window.NLDeploymentIdForLogging; window.NLScriptIdForLogging = 'customscript_cmb_ue_pfa'; window.NLDeploymentIdForLogging = 'customdeploy_cmb_ue_pfa'; }mod.remindTreasury(108,1728,2368,2369);} finally{ if (!!window) { window.NLScriptIdForLogging = origScriptIdForLogging; window.NLDeploymentIdForLogging = origDeploymentIdForLogging; }} }); return false;" onmousedown="this.setAttribute('_mousedown','T'); setButtonDown(true, false, this);" onmouseup="this.setAttribute('_mousedown','F'); setButtonDown(false, false, this);" onmouseout="if(this.getAttribute('_mousedown')=='T') setButtonDown(false, false, this);" onmouseover="if(this.getAttribute('_mousedown')=='T') setButtonDown(true, false, this);" _mousedown="F">
remindTreasury(108,1728,2368,2369) in this the last two numbers of the ids of the employees who must get the email notification. but only the first id gets the email
b
there are 4 different parameters there
each one a number
none of the parameters are an array
v
how can i make that as an array?
b
the usual is with square brackets
v
you mean in the code?
b
back to the original task i gave you
log what is being used for the functionName parameter
v
i logged the functionName parameter (isArray function) to check the type. its true for that function
but in CS, the isArray function is false
b
still failing at the task
the functionName isnt an array
logging part of the expression used for the functionName is not the same as logging the functionName
your code probably looks like
Copy code
form.addButton({
                    id : 'custpage_remindtreasury',
                    label : 'Remind Treasury',
                    functionName : 'remindTreasury(' +recordId+ ',' +senderId+ ',' +remindTreasuryRecipients+ ')'
                });
you want to figure out the value in the functionName, so that you can make the connection to what you inspected on the button in the browser
v
yes exactly this is what my code looks like
b
the guess is that you still dont know what string is being passed as the value to the functionName
so you should probably log it
there are other ways, but i dont think they will be easier
v
how to log? i logged before the button like log.debug('remindTreasuryRecipients'); it returns [2368,2369]
how to log the functionName? i really dont know
i am newbie to NS,
b
its a javascript question
mostly around how would you log a value
the value you are using as the functionName is composed of 7 strings concatenated together
so log those 7 strings concatenated together
alternatively you can put it in a variable and log the variable instead
v
how did you find that? could you kindly let me know?
b
'remindTreasury(' +recordId+ ',' +senderId+ ',' +remindTreasuryRecipients+ ')'
is a string composed of 7 other strings, the first being
'remindTreasury('
and the last
')'
v
ah ok. got it
i have assigned to a variable and the vairbale in UE returns remindTreasury(108,1728,2368,2369).
but in CS only 2368 is taken
function remindTreasury(recordId,senderId,arrayRecipients){ var currentRecord = record.load({ type : 'customrecord_2663_file_admin', id : recordId }); log.debug('CSarrayRecipients',arrayRecipients); log.debug('isarray',util.isArray(arrayRecipients)); email.send({ author : senderId, recipients : arrayRecipients, body : 'Notice sent to Treasury', subject : 'Mail on clicking a button' }); currentRecord.setValue({ fieldId : 'custrecord_cmb_notice_treasury', value : true }); currentRecord.save(); location.reload(); }
this is my CS script. is this correct?
b
there are multiple ways to write this
v
no, i mean the function with parameters in the first line?
should i make any changes?
b
remindTreasury(108,1728,2368,2369)
is how your remindTreasury function is being called
can you identify what is being passed in as the first parameter?
v
the first is the record id, second is the senderid
b
actual values, at this point what they stand for doesnt matter
what is the value of the first parameter
s
A relevant quote from this website: https://eloquentjavascript.net/03_functions.html
JavaScript is extremely broad-minded about the number of arguments you pass to a function. If you pass too many, the extra ones are ignored. If you pass too few, the missing parameters get assigned the value
undefined
.
v
Thank you somuch @battk
i did this
i make changes like 'remindTreasury(' +recordId+ ',' +senderId+ ',['+arrayRecipients+ '])'
now both the ids get emails
@scottvonduhn Thank you