Evaluate does not work in XPages (SSJS) - xpages

I have changed this Evaluate function into SSJS but It did not work :(
funcDoc is NotesDocument.
LOTUSSCRIPT:Evaluate({#If(Ar1_Rates = ""; Ar1_Rates_temp; Ar1_Rates : Ar1_Rates_temp)},funcDoc)
SSJS: session.evaluate("#If(Ar = ""; Ar_temp; Ar : Ar_temp)",funcDoc)

Change it to
session.evaluate('#If(Ar = ""; Ar_temp; Ar : Ar_temp)',funcDoc)

Related

Displaying data from CMS_User in kentico

I have user control and I want to fill a drop-down list form control with CMS User table with a condition on it. could you please help me to do it. thank you in advance
for someone who needs, the answer is here (the where condition depends on the type of search you have, so I left it empty) :
public void FillUsers()
{
string where = "";
var UserColumns = UserInfoProvider.GetUsers().Columns("UserID", "FullName", "BusinessUnitId").Where(where).OrderBy("asia_personalcode");
if (UserColumns != null)
{
DataSet ds = UserColumns;
if (!DataHelper.DataSourceIsEmpty(ds))
{
cmbUser.DataSource = ds;
cmbUser.DataTextField = "FullName";
cmbUser.DataValueField = "UserID";
cmbUser.DataBind();
cmbUser.Items.Insert(0, "-");
cmbUser.Items[0]``.Value = "";
}
}
}

Filter text layers using selectedLayers property

I am trying to put a check on type of layer to ensure my function call only applies to a text layer in selected layers (number of selected layers are several hundreds). It seems I am doing some mistake using the typeOf method. Can someone please help?
var myComp = app.project.activeItem;
var selectedLayers = myComp.selectedLayers;
var numLayers = selectedLayers.length;
for(var i=0; i < numLayers; i++){
var mySourceText = selectedLayers[i].property("ADBE Text Properties").property("ADBE Text Document");
var myTextDoc = mySourceText.value;
if (typeOf(selectedLayers[i]) == "TextLayer") {
mySourceText.setValue(trim(myTextDoc));
}
}
function trim(strValue){
var str = new String(strValue);
return str.replace(/(^\s*)|(\s*$)/g,"");
}
The correct boolean test you want is
if (selectedLayers[i] instanceof TextLayer) {
instanceof, and no quotes for TextLayer.

XPages visible formula does not work

I would liek to use the same hide formula in XPages button.
All Fields below is dateTime Field...
Orjinal lotusScript formula is :
OnayG="" | Onaylandi!="" | OnayTalep!=""
if (document1.isEditable())
{
var OnayG = document1.getItemValueDate("OnayG").toString();
var Onaylandi = document1.getItemValueDate("Onaylandi").toString();
var OnayTalep = document1.getItemValueDate("OnayTalep").toString();
if (OnayG =="" || Onaylandi!="" | OnayTalep!="")
{
return false;
}
}
return true;
You have used a single "|" before OnayTalep variable in the if statement. This is the correct code:
if (document1.isEditable())
{
var OnayG = document1.getItemValueDate("OnayG").toString();
var Onaylandi = document1.getItemValueDate("Onaylandi").toString();
var OnayTalep = document1.getItemValueDate("OnayTalep").toString();
if (OnayG =="" || Onaylandi!="" || OnayTalep!="")
{
return false;
}
}
return true;
your logic regarding isEditable is not the same.
your classic notes version says
"if not editable - hide"
but your xpages logic says:
"if not editable - visible"
the confusion may come from the fact that in notes, a tick or a 'true' value is used to hide something, but in xpages, a true value means it is rendered or visible

how to pass the javascript variable value to <portlet:param/> in Liferay 6.2

I am using Liferay 6.2 community, i want to create link using renderrequest. I have code like this :
<script>
for(var i = 0; i < 10; i++){
var myUrl = "<portlet:renderURL var='renderOneUrl'> "+
"<portlet:param name='action' value='renderOne' />"+
"<portlet:param name='id' value='"+i+"' /></portlet:renderURL>"+
"<a href='${renderOneUrl}'> Click to call render method</a>";
$("div.link").append(myUrl);
}
</script>
and this is for java code :
#RenderMapping(params = "action=renderOne")
public String handleRenderOneRequest(RenderRequest request,RenderResponse response,Model model){
System.out.println("akh akh");
String id = request.getParameter("id");
System.out.println("id = "+id);
//var id always received i not '0/1/2/3/etc'
return "detail";
}
My question is why value form <portlet:param name='id' value='"+i+"' /> always received i (the name of that variable), not value form that js.
The scriptlet combines server-side and client-side processing in a way that doesn't make sense. You try to use JSP tag portlet:renderURL with JavaScript variable i as parameter.
Fortunately, the portlet urls can be created in JavaScript.
<script>
for(var i = 0; i < 10; i++){
var myUrl = Liferay.PortletURL.createRenderURL();
myUrl.setParameter('action', 'renderOne');
myUrl.setParameter('id', i);
var link = "<a href='" + myUrl.toString() + "'>Click to call render method</a>";
$("div.link").append(link);
}
See Creating Portlet URLs in JavaScript for details.

Use other Part instead of TitlePart in menu

I have a menu that has alot of query links. That will generate a good menu with the content of the TitlePart as the text.
I would like to use another parts field, that I have made, instead of the text in the TitlePart. Only in the menu and not on the contents page.
Is there a possibility to modify some module in order to achive this or is there a placement I can use to solve the problem??
I solved the problem by inserting this
protected override void GetItemMetadata(GetContentItemMetadataContext context)
{
var part = context.ContentItem.As<ReferenceCompanyPart>();
if (part != null && part.CompanyName!= null && part.CompanyName != "") {
context.Metadata.DisplayText = part.CompanyName;
}
else {
var titlepart = context.ContentItem.As<ITitleAspect>();
context.Metadata.DisplayText = titlepart != null ? titlepart.Title : "";
}
}
Then my ReferenceCompanyName was used insted of the TitlePart in the menu

Resources