How can I get the label of the link that is clicked by the user?
I have tried:
var elem=document.getElementById("#{id:link1}");var lbl=elem.label;
But this is not returning the label name.
The "label" property of a Link control is called text so the following server-side Javascript will get you the value of the label of the link and store the value in the variable "label":
var linkControl = getComponent("linkExample");
var label = linkControl.getText();
In Xpages [xp:label] tags turn into [span] tags so on csjs you have to use the innerHTML to get the value so your original code would have worked had it been.
var elem=document.getElementById("#{id:link1}");
var lbl=elem.innerHTML;
Related
I have an older Suitescript 1.0 user event script where on the BeforeLoad I change a label on a button in a sublist. (note this is a button on the sublist not on the main header of the form
In order to do that I did something like this:
function changePackageContentsButtonLabel(type, form, request)
{
var mySublist = form.getSubList('recmachcustrecord_tst_my_sublist');
if(mySublist != null)
{
var NewButton = mySublist .getButton('newrecrecmachcustrecord_tst_my_sublist');
if(NewButton != null)
{
NewButton .setLabel('New Label Text');
}
}
}
that worked fine in that i could find the button based on a call to the sublist.getButton
In 2.0 I was wondering how to do that.
I had thought i would call the getButton that is based off the context.form but it does not seem to find the button in that case. And though there are methods to addButton on a sublist, there does not appear to be a getButton on it. I know i could use JQuery but that may be a bit more brittle it seems.
In the Netsuite help section search for
SuiteScript 1.0 to SuiteScript 2.0 API Map
After you get the button object, use label property to get or set a value for the button label.
var myButton = form.getButton({
id : 'buttonid'
});
myButton.label = "New Label Text"
I ended up having to put the logic I wanted into a client script and called it off of the pageInit. What I had to do was use native javascript and locate the button (by document.ElementById() and when i got that element I was able to change the value. This was not the desired way but it seems that 2.0 does not allow you to locate a button on a sublist like 1.0 did.
enter image description hereHi In My Xpages application, I would like to take reference of HTML stored in NotesDocument richtext field( Cofiguration document in Notes Client ), so in Xpages data source I mentioned configDoc as source as Notes Domino Document and in Default Action I set it to " Open Document" and in Document id " I set Computed value as below"
var vw:NotesView = database.getView("vwConfig")
var doc:NotesDocument = vw.getFirstDocument()
var uniid:String = doc.getUniversalID();
return uniid
In one of the place I placed on computedField property, I mentioned ssjs code as
return configDoc.getValue("RTFIeldasHTML").getHTML();
this works if I open document but does not work if I open existing document and it gives me an error:
Error while executing JavaScript computed expression
docConfig.getValue()' is null
Most likely cause is docConfig doesn't have ignoreRequestParams="true". That means it's opening the document whose ID is in the URL and ignore anything you put in the documentId property. Set that and it will work correctly.
I've got a view control which opens an xpage. When the xpage opens, the beforePageLoad event fires. It checks to see if there are any attachments in a particular field of the document being opened and if there are, it returns list of the filenames. This was working fine. Then, I was asked to change what's displayed in one of the columns of the view. I added a variable to the view control's data section to access the row. I then added some javascript to the column to display the data differently. That worked and it displayed the data as wanted. However, when I now click on the link to open the xpage, when the beforePageLoad event fires, the code that's there now fails. It fails with this error at the starred line:
Script interpreter error, line=9, col=49: 'closureField' is null at
[/Function_ReturnListOfClosureAttachmentNames.jss].ReturnListOfClosureAttachmentNames(CCEB1351591847CB85257E7C005EF68C)
function ReturnListOfClosureAttachmentNames(ltDoc ){
var closureAttachmentFileNames = "";
var thisLT = ltDoc;
var closureField:NotesRichTextItem = thisLT.getFirstItem("closeAttachments");
*>>> var eos:java.util.Vector = closureField.getEmbeddedObjects();<<<
var eosi:java.util.Iterator = eos.iterator();
while (eosi.hasNext()) {
var eo:NotesEmbeddedObject = eosi.next();
closureAttachmentFileNames = closureAttachmentFileNames +","+eo.getName();
}
return closureAttachmentFileNames;
}
I call this function from the beforePageLoad event and pass it currentDocument.getDocument(). I think I might have lost the document context after changing the column display data from 'view column' to 'computed value' but I'm not sure. Any ideas would be appreciated.
thanks!
Clem
Figured it out: When I assigned a variable to the view, when you click on a linked column in that view, it loads the current ViewEntry into the context and not a current document. So I put the unid of the doc from the selected ViewEntry in an application scope variable and returned it to the Document Id property when I open the xPage. I have to now update all my views but there aren't too many luckily. Thanks for working through this with me!
Clem –
I'm working on a Custom Control that displays markers on Google Maps. I have a couple of properties like "maptype" , "zoom", etc. It is easy to access them in Javascript: I can use #{javascript:compositeData.zoom} to get the value of the zoom property.
Now this is my problem: I use a group of properties for each marker.
The name of the group is "marker" and a marker has 6 properties: "title", "layer", "infotext", "icon", "address" and "animation".
If I try to access the group with
var markers = #{javascript:compositeData.marker};
I'm getting an error in firebug:
missing : after property id var markers = [{layer=2,
address=Oldenzaal, animation=DROP, icon=/ogo_notes.png...
an arrow is pointing to the first = between layer and 2
(I am not allowed to put in an image in stackoverflow)
If I use
var markers = #{javascript:'"' + compositeData.marker + '"'};
markers is an Object, but each Object contains a string with all the propperties of the marker.
I know I can do some coding to make an object of each string, but this is not easy if not all propperties are required. If a propperty is not required than it will not show up in the string.
I guess that there must be a more easy way to get each marker as an object so I can get the value of the icon with code like:
var icon = marker.icon
How can I do this?
You can use compositeData.marker.icon to get the property icon inside the group marker. If you have checked "Allow multiple instances" for the group then to get the properties you will have to go:
compositeData.marker[0].icon
compositeData.marker[1].icon
and so on...
Update 26-Apr-2012 (Naveen)
To use it with client side javascript you can try to put the value in a hidden input field like this:
<xp:inputHidden id="hdnIcon">
<xp:this.defaultValue><![CDATA[#{javascript:var value = new Array();
for (var i=0 ; i<compositeData.marker.length ; i++) {
value.push(compositeData.marker[i].icon);
}
return #Implode(value, ",");}]]></xp:this.defaultValue>
</xp:inputHidden>
The value of this hidden input field can be read through client-side javascript like this:
var value = document.getElementById("#{id:hdnIcon}").value.split(",");
for (var i=0 ; i<value.length ; i++) {
<YOUR CODE>
}
Another way to do this can be to convert compositeData.marker and its contents to a JSON string and then run the client-side javascript on it.
Each input field in the CKEditor dialogs are renamed with a unique number, but the number changes depending on what options are visible.
I need to reference 'txtUrl' which has an id something like #35_textInput.
So far I have discovered that something like this should work:
alert(CKEDITOR.instances.myElement.document.$.body.getId('txtUrl'));
But it doesn't. Please help.
#Rio, your solution was really close! This was the final solution:
var dialog = CKEDITOR.dialog.getCurrent();
dialog.setValueof('info','txtUrl',"http://google.com");
return false;
var dialog = this.getDialog();
var elem = dialog.getContentElement('info','txtUrl');
within an onchange part of an element I now use
dialog = this.getDialog();
alert(dialog.getContentElement('info', 'grootte').getInputElement().$.id);
and it gives 'cke_117_select' as a result. (It's a selectbox)
alert(dialog.getContentElement('info', 'txtUrl').getInputElement().$.id);
gives 'cke_107_textInput'.
I think this is what you (or other visitors to this page) are looking for.
SetValueOf still doesn't provide the id, which you may need if you want to do more than fill a text field with a certain text.