Does anyone know why N/currentRecord module would ...
# suitescript
n
Does anyone know why N/currentRecord module would "not exist" in a clientscript script type?
c
the entrypoint of a CS script is a currentRecord instance
n
ah ok so no need to define it?
e
Did you make sure that the order of the parameters reflects your define statement?
n
this is what I have so far...bear with me as I'm very new to scripting and would love to learn !
b
You are missing N/currentRecord in the first parameter of your define
n
i had it before and it was giving me the error that the module did not exist
b
What did you have before
n
define(['N/currentRecord','N/log']
b
Full thing
n
Untitled
b
What error where you getting
n
in the debugger it was saying that the module did not exist
i got it working just fine in 1.0
Untitled
disregard comments, etc.
b
works normally for me
are you sure you dont have any other scripts in your account
n
hm yes there are other scripts
b
i would say disable the other client scripts and give it a try
n
alright thanks i'll give that a shot
b
that said, you shouldn't need to use N/currentRecord in the code you shared
Copy code
var recCurrent = context.currentRecord;
should be all you need, as mentioned by Carlos earlier
e
log is global also
n
I must be missing something really simple because I deploy it and it seems like nothing is happening at all
c
is the script on testing or deploy?
because while on testing only the owner can see trigger the script
n
right now the status is : released (I'm in sandbox)
event type is blank, applies to: opportunity, log level: debug
and it is deployed
b
For testing status, only the owner runs the script
For deployed atatus, only the defined script audience on the deployment record runs the script
n
yeah its set to run for all roles right now
guys, I figured it out
I had to add ".js" to the file cabinet extensiot
thank you all for your help !
other questions for all.. i'm trying to use getCurrentSublistValue to loop through the lines in the sublist (so far that's working) but the value I'm getting is blank for some reason...
e
Share your code...
n
Untitled
e
First off no need for line param when you're using getCurrentSublistValue with currentRecord...
and are you sure that this is the correct field id -> custrecordrsm_rev_proj_percent. shouldn't it be custrecord_rsm_rev_proj_percent
n
alright so I don't need any line parameter to loop through and sum?
also for the field ID if I navigate to the custom record it is written like so: custrecordrsm_rev_proj_percent
e
what are you getting for this line — log.debug({details: ‘Looping on line: ’ + i + ‘. Current quantity is :’ + revenuepercent + ‘. Current total is : ’ + total});
n
I'm getting : Looping on line: 1. Current quantity is:. Currentotal is : NaN "" 2 "" 3
b
Your total variable starts as undefined
e
You might also want to create a check for null values and return a value of zero for those that have nulls. NaN means that your equation is trying to add null values.
b
Using undefined for math gives NaN
Line 59 where total is set to 1 is unlikely to be what you want
n
yeah I get that.. just seems like I'm not picking up sublist / field values at all
b
GetCurrentSublistValue only works for the currently selected line
You manipulate the current line by using selectLine
you are better off using getSublistValue if you are only getting values
n
gotcha - and you need the N/record module for that if I'm not mistaken
I'll try that tomorrow !