View Panel cannot locate data var rowData - not found error - xpages

I have a View Panel in a tabbed panel that has the data > var property set to rowData. I have this view set to mimic the Single Category view by using a viewScope value.
When I open a XPage and click on the tab which the view panel exists, sometimes this error pops up (line 2 in the JavaScript Code is where the error is):
Unexpected runtime error
The runtime has encountered an unexpected error.
Error source
Page Name:/speakerReq.xsp
Control Id: viewColumn2
Exception
Error while executing JavaScript computed expression
Script interpreter error, line=2, col=23: [ReferenceError] 'rowData' not found
JavaScript code
1: var href = facesContext.getExternalContext().getRequest().getContextPath();
**2: var docUNID = rowData.getDocument().getUniversalID();**
3: var formName = rowData.getDocument().getItemValueString("Form");
4: var formType = rowData.getColumnValue("Form")
5:
6: if(formName == "clientProfile") {
7: href + "/clientProfile.xsp?documentId=" + docUNID + "&action=openDocument&rtr=yes";
8: }
9: else {
10: href + "/speakerProfile.xsp?documentId=" + docUNID + "&action=openDocument&rtr=yes";
11: }
The viewColumn2 that is referenced above is a column in the view which has this formula:
#ReplaceSubstring(Form; "clientProfile" : "clientFeed" : "speakerProfile" : "speakerFeed"; "Client Profile" : "Client Feedback" : "Speaker Profile" : "Speaker Feedback")
I am not sure how that would throw the error above --- clicking on that tab on most XPages works fine.
The documents that are being displayed in the view are nothing special. I compared two of them -- one that displays and one that throws the error and I could not find any differences that would cause this problem.
I cannot determine why sometimes the error appears and sometimes not.
Any help would be great!

try to use a different variable name curRowData --- and don't forget that stuff is case sensitive. Also your code is a big fat memory leak since rowData.getDocument initializes a NotesDocument that you don't recycle.
Try to use:
var result;
if (curRowData.isCategory()) {
return "";
}
var href = facesContext.getExternalContext().getRequest().getContextPath();
try {
var doc = curRowData.getDocument();
if (doc != null) {
var docUNID = doc.getUniversalID();
var formName = doc.getItemValueString("Form");
var formType = curRowData.getColumnValue("Form")
if(formName == "clientProfile") {
result = href + "/clientProfile.xsp?documentId=" + docUNID + "&action=openDocument&rtr=yes";
} else {
result = href + "/speakerProfile.xsp?documentId=" + docUNID + "&action=openDocument&rtr=yes";
}
}
} catch (e) {
// some error handling
}
if (doc != null) {
doc.recyle();
}
return result;
Of course you would be better off just to add all values you need to the view. Saves you the need to create a NotesDocument object

Perhaps this error occurs if the view is categorized and the code hits a category and not a document. You can use the folllowing code to make sure that the current row is not a category:
if (!rowdata.isCategory()) {
// insert your code here
}
This code of course assumes that rowData is available so this might not solve your issue.
Example code can be found in the Notes & Domino Application Development wiki:
http://www-10.lotus.com/ldd/ddwiki.nsf/dx/notesxspviewentry_sample_javascript_code_for_xpages#isCategory+isDocument+isTotal

Please add a description of the XML declaring the control.
I have myself gotten this error and it was because I computed the column in a wrong way; "Computed" vs JavaScript I think it was…

Related

Viewing file properties instead of file in SharePoint document library

I have a document library on SharePoint online with lots of columns for metadata. These columns won't fit in a single view on screen, so I want the users to first view the properties of the file before downloading them.
Is there a way to change the behavior of the SharePoint library ensure that the user views the file properties first when they click on the filename?
PS: I understand I could have used lists, but after loading about 10000 documents, I have decided to use it as a last resort. Thank you.
Custom the LinkFilename field by CSR.
Sample code:
(function () {
'use strict';
var CustomWidthCtx = {};
/**
* Initialization
*/
function init() {
CustomWidthCtx.Templates = {};
CustomWidthCtx.Templates.Fields = {
'LinkFilename': {
'View': customDisplay
}
};
// Register the custom template
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(CustomWidthCtx);
}
/**
* Rendering template
*/
function customDisplay(ctx) {
var currentVal = '';
//from the context get the current item and it's value
if (ctx != null && ctx.CurrentItem != null)
currentVal = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
var el = "<div class='ms-vb itx' id='" + ctx.CurrentItem.ID + "' app='' ctxname='ctx37'><a title='" + ctx.CurrentItem._ShortcutUrl + "' class='ms-listlink ms-draggable' aria-label='Shortcut file' onfocus='OnLink(this)' href='/Doc4/Forms/EditForm.aspx?ID=" + ctx.CurrentItem.ID + "' target='_blank' DragId='17'>" + ctx.CurrentItem.FileLeafRef + "</a></div>";
// Render the HTML5 file input in place of the OOTB
return el;
}
// Run our intiialization
init();
})();

Netsuite Email Merge Error (SSS_MERGER_ERROR_OCCURRED)

I'm creating a Scheduled SuiteScript in Netsuite that uses the 1.0 version of the API. The goal is to have the script run once per day to send our first time customers an email with their name (or company name) and other pre-formatted content using a Scriptable Email Template.
Once it is up and running, we are planning to extend it with additional functionality, but this is the base that we would like to have running before adding additional code.
The error message is:
SSS_MERGER_ERROR_OCCURRED - Merger error occurred: Unexpected error encountered during merging.
Everything goes smooth up until actually using .merge(). I've added the code below:
function thankyouletter() {
var searchresults = nlapiSearchRecord(null, 'customsearch127'); // minus: , filters
if (searchresults == null) {
response.write('Var searchresults is null.');
return;
} else {
nlapiLogExecution('DEBUG', 'START - Found search results', 'Starting iteration');
for (var i = 0; searchresults != null && i < searchresults.length; i++) {
var searchresult = searchresults[i];
var searchCols = searchresult.getAllColumns();
var internalid = searchresult.getId(); // Will be used after testing is finished
var emailMerger = nlapiCreateEmailMerger(38);
emailMerger.setEntity('customer', 24886); // Set for Testing
var mergeResult = emailMerger.merge(); // Fails and errors here
var emailSubject = mergeResult.getSubject();
var emailBody = mergeResult.getBody();
nlapiSendEmail(nlapiGetUser(), customerid, emailSubject, emailBody, null, null, null, null);
nlapiLogExecution('DEBUG', 'Merge Troubleshooting', 'Just after SendEmail');
}
}
var usageRemaining = context.getRemainingUsage();
nlapiLogExecution('DEBUG', 'usage left => ' + usageRemaining);
nlapiLogExecution('DEBUG', 'Script Finished.', 'Mission Complete');
}
I've removed some of the nlapiLogExecution lines for readability. If anything is confusing or additional info is needed, please let me know and I'll add/fix it.
I've dug through piles of Netsuite's documentation, SuiteAnswers, and web searches trying to find the solution, but the error message is pretty vague.
Any help is greatly appreciated! Thank you.
After further research, I found that the Freemarker Template had a syntax error, and that was causing the error.

Using getAttribute to get the class name of a webelement in Native context

Went through the java docs of getAttribute. Couldn't understand the point mentioned as :
Finally, the following commonly mis-capitalized attribute/property
names are evaluated as expected: "class" "readonly"
Could someone confirm if webElement.getAttribute("class") shall return the class name of the element or not?
Edit : On trying this myself
System.out.println("element " + webElement.getAttribute("class"));
I am getting
org.openqa.selenium.NoSuchElementException
Note : The element does exist on the screen as I can perform actions successfully on the element :
webElement.click(); //runs successfully
Code:
WebElement webElement = <findElement using some locator strategy>;
System.out.println("element " + webElement.getAttribute("class"));
So the answer to the problem was answered on GitHub in the issues list of appium/java-client by #SergeyTikhomirov. Simple solution to this is accessing the className property as following :
webElement.getAttribute("className")); //instead of 'class' as mentioned in the doc
Method core implementation here : AndroidElement
According to this answer, yes you are doing it right. Your org.openqa.selenium.NoSuchElementException is thrown because selenium can't find the element itself.
The sidenote you have posted, about webElement.click() actually working, is unfortunately not included in the code you have posted. Since it is not a part of the actual question, I leave this answer without adressing it.
public String getStringAttribute(final String attr)
throws UiObjectNotFoundException, NoAttributeFoundException {
String res;
if (attr.equals("name")) {
res = getContentDesc();
if (res.equals("")) {
res = getText();
}
} else if (attr.equals("contentDescription")) {
res = getContentDesc();
} else if (attr.equals("text")) {
res = getText();
} else if (attr.equals("className")) {
res = getClassName();
} else if (attr.equals("resourceId")) {
res = getResourceId();
} else {
throw new NoAttributeFoundException(attr);
}
return res;
}

error on a dojo grid when adding new item to the store

I'm stuck with a problem on a dojo grid when adding new item to the store.
I've got :
a dojox/grid/EnhancedGrid containing articles
a tabcontainer where the tabs represent article's family.
Each time I choose a tab , it filters the grid to display that family, so far everything work fine.
But I've a button that allows to add a new article to the grid through a new window.
If the grid is not filtered no problem , but if i've got a tab selected I get the error:
grid assertion failed in itemwritestore
Same error on FF and IE, I search internet for that error but i didn't find anything revelant.
My code if its helps ...
var grid=parent.registry.byId('lagrid');
var items=lagrid.store._arrayOfAllItems;
var item=items[e.rowIndex];
var lestab=parent.registry.byId( 'TabContainerRayon');
var tabsel=lestab.selectedChildWidget.id
var ongletR=tabsel.substring(1,tabsel.length);
if (grid)
{
var storeParent=grid.store;
var itemsParent=storeParent._arrayOfAllItems;
for (i=0 ; i< itemsParent.length ; i++)
{
if (itemsParent[i].col17==idLigne)
{
alert("Article déjà présent");
return false;
}
}
var myNewItem = {
id: grid.rowCount+1,
col2:trim(lagrid.store.getValue(lagrid.getItem(e.rowIndex),"Col5")),
col3:undefined,
col4:undefined,
col5:trim(lagrid.store.getValue(lagrid.getItem(e.rowIndex),"Col6")),
col6:trim(lagrid.store.getValue(lagrid.getItem(e.rowIndex),"Col8")),
col7:undefined,
col8: undefined,
col9: undefined,
col10: 1,
col11: undefined,
col12:trim(lagrid.store.getValue(lagrid.getItem(tabInd[0]),"Col1")),
col13:trim(lagrid.store.getValue(lagrid.getItem(e.rowIndex),"Col2")),
col14:'' ,
col15: ongletR,
col16:"<img src='/" + CheminBase + "/pictures.png?OpenImageResource' border=0>",
col17:idLigne ,
col18:trim(lagrid.store.getValue(lagrid.getItem(e.rowIndex),"Col9"))
};
parent.PctPrixTolere.push(parseInt(lagrid.store.getValue(lagrid.getItem(e.rowIndex),"Col7")));
parent.PresenceReleve.push("0");
}
// ajoute l'item dans le store
grid.store.newItem(myNewItem);
grid.store.save();
parent.registry.byId('external').hide();
Thanks for your help
ok I finally find my mistake thanks to ie debugger :)
in fact I was using grid.rowCount+1 to identify my new item, but if I click onto a tab, I have always less row than the store has => same id than an existing row => assertion failed. I changed that to grid.store._arrayOfAllItems.length and it works fine :)

recognize multple lines on info.selectionText from Context Menu

My extension adds a context menu whenever a user selects some text on the page.
Then, using info.selectionText, I use the selected text on a function executed whenever the user selects one of the items from my context menu. (from http://code.google.com/chrome/extensions/contextMenus.html)
So far, all works ok.
Now, I got this cool request from one of the extension users, to execute that same function once per line of the selected text.
A user would select, for example, 3 lines of text, and my function would be called 3 times, once per line, with the corresponding line of text.
I haven't been able to split the info.selectionText so far, in order to recognize each line...
info.selectionText returns a single line of text, and could not find a way to split it.
Anyone knows if there's a way to do so? is there any "hidden" character to use for the split?
Thanks in advance... in case you're interested, here's the link to the extension
https://chrome.google.com/webstore/detail/aagminaekdpcfimcbhknlgjmpnnnmooo
Ok, as OnClickData's selectionText is only ever going to be text you'll never be able to do it using this approach.
What I would do then is inject a content script into each page and use something similar to the below example (as inspired by reading this SO post - get selected text's html in div)
You could still use the context menu OnClickData hook like you do now but when you receive it instead of reading selectionText you use the event notification to then trigger your context script to read the selection using x.Selector.getSelected() instead. That should give you what you want. The text stays selected in your extension after using the context menu so you should have no problem reading the selected text.
if (!window.x) {
x = {};
}
// https://stackoverflow.com/questions/5669448/get-selected-texts-html-in-div
x.Selector = {};
x.Selector.getSelected = function() {
var html = "";
if (typeof window.getSelection != "undefined") {
var sel = window.getSelection();
if (sel.rangeCount) {
var container = document.createElement("div");
for (var i = 0, len = sel.rangeCount; i < len; ++i) {
container.appendChild(sel.getRangeAt(i).cloneContents());
}
html = container.innerHTML;
}
} else if (typeof document.selection != "undefined") {
if (document.selection.type == "Text") {
html = document.selection.createRange().htmlText;
}
}
return html;
}
$(document).ready(function() {
$(document).bind("mouseup", function() {
var mytext = x.Selector.getSelected();
alert(mytext);
console.log(mytext);
});
});​
http://jsfiddle.net/richhollis/vfBGJ/4/
See also: Chrome Extension: how to capture selected text and send to a web service

Resources