using qtip in xpages - xpages

i'm trying to display qtip2 for certain xpage Components. To make it generic, i have created a custom control which has (fieldID & componentID as custom properties). i have a view which has all fieldID's and associated help text for each id ( which is unique)
My problem is that i'm unable to call a SSJS function from CSJS with input parameters. Please see my code below. if i hardcode fieldID (getFieldHelp('"+fieldID+"')) everything works fine but when i pass variable it will return null value. Any help will be greatly appreciated. thanks in advance.
script block
<xp:scriptBlock id="scriptBlock2"
value="var fieldID=#{compositeData.fieldID};var componentID=#{compositeData.componentID};">
</xp:scriptBlock>
on client load event
alert(componentID+"~~~~~~~~~~~"+fieldID)
var helpContent="#{javascript:getFieldHelp('"+fieldID+"')}"
alert(helpContent)
$(document).ready(function()
{
x$("#{id:link_Test}").qtip({
//x$(compid).qtip({
content: "helpContent",
style: 'qtip-tipsy qtip-shadow'
});
});

This will not work. If you want to send a ClientSide variable 'fieldID' to a SSJS (getFieldHelp) you have to use something like the ExecuteOnServer function from Jeremy Hodge. because you have to POST this variable to the Server.
But why dont you use:
var helpContent ="#{javascript:getFieldHelp(compositeData.fieldID)}"
assuming that getFieldHelp is a SSJS function and both code snippets are in the same component. =)
(maby you have to Change the # to $ to get the compositeData.)
update:
I did some testing on getting the compositeData.FieldID in an CSJS onClientLoad event.
What i came up with is this:
<xp:scriptBlock>
<xp:this.value><![CDATA[XSP.addOnLoad(function(){
alert("#{javascript:return compositeData.fieldId}");
});]]></xp:this.value>
</xp:scriptBlock>
I use the XSP.addOnLoad() to execute the CSJS (onClientLoad) and inside the xp:scriptBlock i can pass the compositeData to the client side.

Related

How do I add button in NetSuite client script and use it as trigger for script function?

I'm trying to add a button to the current record with the Client Script button definition on a script record, but for some reason it's not finding my function. I'm returning my function tryThisand there is a button on the page which I created on the script record with the function tryThis defined in the appropriate field, but the code doesn't run. Here's my script:
define (['N/currentRecord','N/search','N/record'] ,
function(currentRecord,search,record) {
function tryThis(context){
log.debug({
title: 'try this',
details: 'try this'
});
}
function pageInit(context) {
}
return {
pageInit: pageInit,
tryThis: tryThis
};
});
Nothing happens :(
Yes, the script is deployed.
How can I use this button on a client script??
This doesn't exactly answer your question directly, but I hope it may help. I tested this, and there appears to be nothing wrong with the way you've set it up - the only thing that seems to be not working is the log module, which I've come across before in client scripts.
Try running your function using a console.log() or alert() instead (both work for me).
Hopefully someone with more detailed knowledge of the N/log module's design and behavior will chip in, as the documentation seems to indicate that this should work.
At the bottom of your Client Script record in Edit mode you will find where you can easily set the button and function to call.

Netsuite Suitelet addButton call function

I am struggling to find a way to add a button to a Suitelet that calls another function in the same suitelet. I have tried many things but I can not get anything to work. I also tried to create a client script and call the client script but the issue with that solution is I need to call another function in the Suitelet from the client script.
function Image(request, response){
var form = nlapiCreateForm("Today's Checks", true);
function next(count){
//code here
showImage(imageId);//call to another function
}
form.addButton('custpage_next','Next',"next();");
response.writePage(form);
showImage(id){
//more code . . .
}
}
The suitelet runs server side. You need to enable client side code.
Put the code you need into another file and use it to create a client script.
Give it a useful id when you create it. You don't need to deploy the script.
Then
form.setScript('customscript_clientscriptid');
Then you can use the functions from that file in your button code.

Why won't my suitescript deploy scripts fire?

I don't know when this started, but I think it happened after I did some refactoring using the IDE with renaming.
Anyway, if I attach the script through the form, they fire. However, my user event, nor client scripts fire though there is a deployment record. That deployment record uses the same script that works IF it is attached via the form custom code area.
What happened?
EDIT:
For Instance:
Trying to add a button to opportunity:
function userEventBeforeLoad(type, form, request){
var list = form.getSubList("item");
list.addButton('custpage_customconfigurebutton', 'Configure', 'clientStartConfigurator()');
}
Upload Script
Add to "Script"
Deploy:
It never fires when I "Create Opportunity"?
NONE of my user event scripts are firing
EDIT 2 (NEW SCREENS as requested
Following lines of code working for me
function userEventBeforeLoad(type, form, request) {
//nlapiLogExecution('error', 'type', type);
var list = form.getSubList("item");
list.addButton('custpage_customconfigurebutton', 'Configure',"alert('Hello World')");
}
I suspect you might have an error in your clientStartConfigurator(). To verify, you can also use the browser console on click of your button to see whether you're successfully returning from your respective function or not.
Hope this will help you.

Scope of exported variable in express and jade

I'm having a few issues with Jade and scope of variables exported from the route. This might be an obvious answer, but my googling abilities have failed me.
In my route, I have this code :
res.render('index', {title: "App",
csvData: json // This is a json object
};
In my view, I want to display the length of the json object on the click of a button. My jade looks like this :
extends layout
block content
script
-var test123 = csvData;
-console.log(test123.length);
div
button.btnCSV(onclick='console.log(test123)') Save As CSV
The first console.log prints the correct length, but when I do press the button, it tells me that test123 is undefined. I think this has something to do with the difference between client side/server side variables. If that is the case, is there anyway to make a server side variable accessible to a client side scope?
I'm not sure how your example would work with the script content prefixed with a -, this indicates unbuffered code. JavaScript that runs server side and that produces no direct output, so your in-line script is most likely empty.
Similarly your onclick handler is just compiling a string on the server, which is the main problem you appear to report.
In order to achieve what you trying to do, you should define a function in the script block which can be called from your buttons onclick handler. Take care to ensure that your script keyword ends with a . so that the following lines are treated as block content of the script.
Here's what your template should look like.
extends layout
block content
script.
var test123 = !{JSON.stringify(csvData)};
function printLength() {
console.log(test123.length);
}
div
button.btnCSV(onclick='printLength()') Save As CSV
Then on the server side make sure you're returning an actual JavaScript object, or an Array, and not a string representation... it should look like this
res.render('index', {title: "App",
csvData: [{ val1: 'value1', val2: 'value2' }]
};
This allows variables to be used for server side scripting (if required) as well as client side.

Setting value of a djDateTextBox and djTimeTextBox?

How do I set the value of a djDateTextBox and djTimeTextBox component?
I tried
getComponent("djDateTextBox1").setValue("10/12/2012");
but that does not seem to work.
for me, this code here works just fine (is called by a button's server side onclick event, performing a full update):
getComponent("djDateTextBox1").setValue(#Today());
Otherwise you also could achieve a similar result using some client side script as in
dojo.byId("#{id:djDateTextBox1}").value = new Date();
Thanks to Lothar for putting me on the right track but this is how I solved it:
var sdt:NotesDateTime = doc.getItemValueDateTimeArray("ContractorStartDateTime")[0];
var fdt:NotesDateTime = doc.getItemValueDateTimeArray("ContractorFinishDateTime")[0];
getComponent("djDateTextBox1").setValue(sdt.toJavaDate());
getComponent("djTimeTextBox1").setValue(sdt.toJavaDate());
getComponent("djDateTextBox2").setValue(fdt.toJavaDate());
getComponent("djTimeTextBox2").setValue(fdt.toJavaDate());

Resources