Set field value - netsuite

I have userevent script that I need to add a + 1 value to a field on edit.
This is what I have so far:
nlapiSubmitField('custbody1', + '1');
I am receiving an error, invalid expression. Please assist if you can.
Thanks

+ '1' is not valid JavaScript syntax.
You will need to retrieve the current value from custbody1 (presumably with a lookup), parse it as a Number, add 1 to the result, then that result is what you will pass to nlapiSubmitField.

You will need to store the returned value of nlapiGetFieldValue in a variable before using nlapiSetFieldValue. Something like:
var x = nlapiGetFieldValue('field1');
nlapiSetFieldValue('field1', parseInt(x) +1);

Related

How do I check if a variable exists before I set a form value equal to it in Jade: Template Engine

I want to set the value of a username form equal to the previously entered username if it exists in jade.
input.box(type = "text" name = "username" placeholder = "Username" value=`${username}`)
My current code looks like this but if I don't pass in a value for username, the value is set to undefined. How do I implement a check to see if the variable exists before the value is set to the username variable?
Cheers
You can use the ternary operator to do this:
value= username ? username : 'no username'
In this case undefined is going to evaluate to false and trigger the second option in the ternary statement.
Also note that you don't need to use ${} when you're inside a pug element.
input.box(value=`${username}`)
will produce the same output as
input.box(value= username)
The second one is far easier to understand quickly.

Convert the parsed T&Z timestamp to millisecond

1) In response, a time stamp returned and is in T&Z format, ex: “2018-10-09T10:10:00Z”.
2) I have parsed the date and saved in a variable(date1) using “Regular Expression Extractor”.
3) In the successive request I would need to use the parsed time but this time I want to use it in millisecond format for the next request.
4) Here is my sample snippet looks like in “BSF PreProcessor”,
Here “date1” is a variable to which the value is parsed and extracted using Regular Expression Extractor.
Code snippet,
var time1 = vars.get(date1);
var timem1 = new Date(time1);
var timem1 = timem1.getTime();
vars.put("timem1",timem1);
But the above code didn’t help.
Can anyone please help me here?
Thanks in advance.
This is the format Instant can directly parse:
java.time.Instant.parse('2018-10-09T10:10:00Z').toEpochMilli()
// => 1539079800000
Please check the below;-
String b1 = "2018-10-09T10:10:00Z";
time=Date.parse("yyyy-MM-dd'T'HH:mm:ss'Z'", b1)
// get epoch milis
epoch_milis = time.getTime()
log.info("Current date in the specified format:>>>>>>>>>>>> " + epoch_milis);
Please check if this helps.
Also, it is recommended to use JSR223 instead of beanshell due to performance.

Ampscript BuildRowsetFromString() fails on single item

I've been tasked with an ExactTarget task, which uses Ampscript. Trying to learn on the go here. See code snippet below:
%%[
Var #testString, #testOutput
Set #testString = Qwerty
Set #testOutput = BuildRowsetFromString(#testString,"~")
]%%
TestOutput:%%= v(#testOutput) =%%
The code works if the testString contains a ~, but when there is no ~ character in the string, the ouput is blank. Is this correct by design? Do I need to add a conditional to check for the presence of the ~ character?
That's the expected behavior. The BuildRowsetFromString() function alone isn't going to return any value when displayed, you're going to need to use Row() and Field() in order to pull the value out.
Using your example:
%%[
Var #testString, #testOutput
Set #testString = "Qwerty"
Set #testOutput = BuildRowsetFromString(#testString,"~")
]%%
RowCount: %%=RowCount(#testOutput)=%%
TestOutput: %%=v(#testOutput)=%%
The RowCount() function returns a value of 1, essentially saying it knows there's at least one 'row' in there. To display that one value, you'll need to wrap that value with Field() and Row():
TestOutput: %%=Field(Row(#testOutput,1),1)=%%
If you want to display other values in the string, say you were passing "Qwerty~Second~Third", you'll need to either change the number at the Row() function or perform a loop.
References
Using Loops
BuildRowsetFromString() Function

IBM Cognos prompt value when not entered

I have a problem in report studio. please help me to figure this out..
i have a optional prompt, i want to check whether the value is selected or not..
Please help how to check..
if (?parameter? is null ) then ('1') else ('2')
or
if (ParamDisplayValue('parameter') is null ) then ('1') else ('2')
Both the above are not working..
Suppose if i select any value in the prompt then the else part works and i get the result as 2, if i wont select anything then i'm not getting the result as 1
My guess, without doing extensive testing, is that an empty optional prompt doesn't exist at all and can't be compared to null. That said, I believe there's an easy fix.
Since you know that when you select an item '?parameter? is null' will return false, '?parameter? is not null' should return true and you can reverse the logic:
if (?parameter? is not null) then ('2') else ('1')
Try to put a conditional block. Set a block variable of type boolean with this expression:
ParamDisplayValue('myParam') is null
Then go to your conditional block again switch property "current block" to yes/no.
When yes (meaning that our block variable is true so the parameter is null) add a text item and just write "All".
When no add a text item with source type as report expression and write ParamDisplayValue('myParam')
P.S: there is also a way to count how many values the user selected (so as not to display all of them 1 by 1 but just show "62 values selected") but it needs some javascript and a hidden prompt field.
Use ParamCount
More details here:
http://joesanswers.blogspot.com.au/2008/09/checking-for-empty-parameters-in-cognos.html

computed field value in xpages

I am trying to update a computed fields value on click of a button with a value of a edit box + its own value.
Code written on button: here i put value of edit box in scope variable and make edit box blank. comment_te is the name of edit box
requestScope.put("commentValue", getComponent("comments_te").getValue);
getComponent("comments_te").setValue("");
Code written for value of computed field: comments is the name of computed field
getComponent("comments").getValue + "\n" + requestScope.get("commentValue")
But I get the output is:
0 com.ibm.xsp.component.xp.XspInputText#65426542
Please help me with this.
You're missing the parentheses in your calls to getValue(). By omitting these, you're returning a pointer to the getValue method of the component, not the result of invoking that method. Change each reference to getValue to getValue(), and you'll get a different result.
Your code returning the Object.
Try the following.
This following code get the the editbox value and set to a scope variable.
requestScope.commentValue = getComponent("comments_te").value;
getComponent("comments_te").value = "";
This following code sets the value to the computed field.
getComponent("comments").value = getComponent("comments").value + "\n" + requestScope.commentValue;
When you are appending the value to the computed field, as default it will add 0 to its value. Do the validation if you want.
I hope this helps you...!!!

Resources