How to access Liferay Variable value in Workflow context - liferay

I have created a content approver workflow in liferay 6.2. I want to show user name and other variables values which are used in template tag in email subject.
I have added description tag to show email subject but when i try to use variable in this it show variable as string instead of its value.
Below is my template
<actions>
<notification>
<name>Review Notification</name>
<description><![CDATA[${userName}]]> test sent you a <![CDATA[${entryType}]]> for review in the workflow.</description>
<template>${userName} sent you a ${entryType} for review in the workflow.</template>
<template-language>freemarker</template-language>
<notification-type>email</notification-type>
<notification-type>user-notification</notification-type>
<execution-type>onAssignment</execution-type>
</notification>
<notification>
<name>Review Completion Notification</name>
<description>Your submission has been reviewed and the reviewer has applied the following ${taskComments}.</description>
<template>Your submission has been reviewed and the reviewer has applied the following ${taskComments}.</template>
<template-language>freemarker</template-language>
<notification-type>email</notification-type>
<recipients>
<user/>
</recipients>
<execution-type>onExit</execution-type>
</notification>
</actions>
In description tag i have used variable ${username} and ${entryType} but instead showing
"Test sent you a Web Content Article for review in the workflow."
it is showing :
"${userName} sent you a ${entryType} for review in the workflow."
But in email body it is displaying fine. Any Help

Unfortunately, you are not able to pass any variables into this section, assuming you are not making any modification to original Liferay source.
String notificationMessage = notificationMessageGenerator.generateMessage(kaleoNotification.getKaleoClassName(), kaleoNotification.getKaleoClassPK(), kaleoNotification.getName(), kaleoNotification.getTemplateLanguage(), kaleoNotification.getTemplate(), executionContext);
String notificationSubject = kaleoNotification.getDescription();
These lines above are responsible for message creation. As you can see notificationMessage is created using executionContext and some other parameters, which are storing context variables and in the end replacing your token variables with real values. Description is just simple String passed forward, so there is no such replacement done in this case.

Related

DocuSign SOAP API setup default value for a tag

I am using DocuSign SOAP API to create and send an envelope. I need to setup default value for the custom tabs so that the recipients do not have to enter the values during the signing process. Though, I want to give an option to the users to replace the default values.
For some reason, once I setup the default values for the tags, the recipients are not able to change those values during the signing process.
I have referred to the previous posts for the same questions and have setup the following properties to false.
CustomTabRequired = false
CustomTabRequiredSpecified = false
CustomTabLocked = false
CustomTabLockedSpecified = false
Please let me know if I am missing anything.
Thanks,
Minal
CustomTabLocked as false should make it editable, I tested via SOAP UI and its working fine for me, below is the snippet XML for it:
<ns:Tab>
<ns:DocumentID>32093411</ns:DocumentID>
<ns:RecipientID>45399085</ns:RecipientID>
<ns:PageNumber>1</ns:PageNumber>
<ns:XPosition>124</ns:XPosition>
<ns:YPosition>261</ns:YPosition>
<ns:Type>Custom</ns:Type>
<ns:TabLabel>Text b5a8927a-4f93-4288-b280-d15023b1b834</ns:TabLabel>
<ns:CustomTabType>Text</ns:CustomTabType>
<ns:Value>TestValue</ns:Value>
<ns:CustomTabLocked>false</ns:CustomTabLocked>
</ns:Tab>

Need help in sharing the portlet session data in liferay

Actually I am trying to share the data between 2 portlets in a 2 different plugin projects
Below are the steps I followed to share the data :
Step1: Create liferay plugin project named as Senderproj and created one portlet under Senderport then write below code in doView method
PortletSession session=req.getPortletSession();
String s="naresh";
session.setAttribute("gates",s,PortletSession.APPLICATION_SCOPE);
step2: Create liferay plugin project named as Receiverproj and created one portlet named as Receiverport then write below code in doView method
PortletSession ps = req.getPortletSession();
String tabName = (String)ps.getAttribute("gates",PortletSession.APPLICATION_SCOPE);
System.out.println("this is from doView of ipc receiver portlet"+tabName);
Step 3: I added the property in liferay-portlet.xml like below
<private-session-attributes>false</private-session-attributes>
When I drop two portlet in a portal page I got session value null in Receiverport.
can any one help out
Fist check that <private-session-attributes>false</...> is correctly set in both portles (sender and receiver).
Then, set and get session attributes using APPLICATION_SCOPE:
renderRequest.getPortletSession().setAttribute(
"name", "some value", PortletSession.APPLICATION_SCOPE
);
renderRequest.getPortletSession().getAttribute(
"name", PortletSession.APPLICATION_SCOPE
);
So far it seems that's what you're already doing.
If they are on the same page, we must ensure that they are loaded in the correct order. In Liferay this can be achieved by setting the render-weight. (In a real case it is better that they do not depend on the order in which they are loaded.)
<!-- Sender -->
<portlet>
<portlet-name>test-a</portlet-name>
<icon>/icon.png</icon>
<instanceable>true</instanceable>
<private-session-attributes>false</private-session-attributes>
<render-weight>3</render-weight>
...
</portlet>
<!-- Receiver -->
<portlet>
<portlet-name>test-b</portlet-name>
<instanceable>true</instanceable>
<icon>/icon.png</icon>
<private-session-attributes>false</private-session-attributes>
<render-weight>2</render-weight>
...
</portlet>
Besides, this link may be helpful:
Liferay Session Sharing Demystified

#Mailsend in xpages button

In Client Notes programming there is an action button:
#MailSend(Destinatari;"";"";"Subject";"";"";IncludeDoclink])&
#Command([FileSave])&#Command([FileCloseWindow])
I want to make a similar action in my xpage application which works both in XPiNC and web.
My sendto field is a DjTextarea which can have multiple values.
I tried to create a simple action for my button from xpage: Action: Send Mail. In this way, can I embedded < the IncludeDoclink from Lotus Notes> in the body of the mail? Or I need to write a javascript for this action?
Thanks for your time!
UPDATE: following #Lothar suggestions, my Save & Send button has the following code lines:
if(frmDoc.isNewNote()){
frmDoc.save();
}
var thisdoc = frmDoc.getDocument();
var tempdoc = database.createDocument();
tempdoc.replaceItemValue("Form", "Memo");
tempdoc.replaceItemValue("SendTo", thisdoc.getItemValue("txt_names"));
tempdoc.replaceItemValue("Subject", "subject");
var tempbody:NotesRichtextItem = tempdoc.createRichTextItem("Body");
tempbody.appendText("This is my Mail, click on the doc link below to open the original doc:")
tempbody.addNewLine(2);
tempbody.appendDocLink(thisdoc);
tempdoc.send();
thisdoc.recycle();
tempbody.recycle();
tempdoc.recycle();
Where frmDoc is my doc datasource. I get an error like: NotesRichTextItem.appendDocLink(lotus.domino.local.Document) null - at the appendDoclink line. - the same error I noticed in the #Fredrik useful suggestion too.
I use the HTML email function that can be found in xSnippets when sending emails in xpages.
XSnippet SSJS HTML Mime emails
or
XSnippet email Bean
None of them as an function for attaching a doclink, but you could manually add an url to the document.
Another way is to create the email manually by creating a document is the database
adding a richtextfield called body and a subject and a sendto field.
And adding a doclink to the Body field.
var doc:NotesDocument = database.createDocument();
var My_DocLink_Doc:NotesDocument=database.getDocumentByUNID("UNID_of_Document")
doc.replaceItemValue("form", "Memo");
doc.replaceItemValue("sendTo", "the_emailadress");
doc.replaceItemValue("subject", "an email to you");
var RT:NotesRichTextItem=doc.createRichTextItem("Body")
RT.appendText("This is my Text")
RT.addNewLine()
RT.appendDocLink(My_DocLink_Doc)
doc.send();
There's really not much to add to Fredrik's answer, but I'm afraid you might be looking at the wrong pieces of his solution. I just tested it myself, and it's working just fine, so here's the result, step-by-step:
my xpage is bound to a Notes form named testMail using a document datasource called mailDoc. It is built like this:
Control#1 is a textarea with a multiple separator set to a comma, so that I can enter multiple mail addresses separated by commas. The textarea is bound to a Notes field named SendTo:
<xp:inputTextarea
value="#{mailDoc.SendTo}"
id="sendTo1"
multipleSeparator=",">
</xp:inputTextarea>
Control #2 is a simple EditBox control bound to a Notes field named Subject:
<xp:inputText
value="#{mailDoc.Subject}"
id="subject1">
</xp:inputText>
A button control labelled Save & Send first saves the current document if it is New (i.e. has never been saved before), then performs all the necessary steps to send a doclink for the currently opened doc (button's onclick event); in the following code I'm using these variables:
mailDoc = my datasource object;
thisdoc = the backend doc object that the datasource is bound to;
tempdoc = a temp backend doc object used to be sent via Notes mail:
if(mailDoc.isNewNote()){
mailDoc.save();
}
var thisdoc = mailDoc.getDocument();
var tempdoc = database.createDocument();
tempdoc.replaceItemValue("Form", "Memo");
tempdoc.replaceItemValue("SendTo", thisdoc.getItemValue("SendTo"));
tempdoc.replaceItemValue("Subject", thisdoc.getItemValue("Subject"));
var tempbody:NotesRichtextItem = tempdoc.createRichTextItem("Body");
tempbody.appendText("This is my Mail, click on the doc link below to open the original doc:")
tempbody.addNewLine(2);
tempbody.appendDocLink(thisdoc);
tempdoc.send();
thisdoc.recycle();
tempbody.recycle();
tempdoc.recycle();
Result: the button code sends a mail containing a Notes document link to all the recipients that I previously entered in the SendTo field.
If I set the testMail form's property to use the Xpage in Notes (Defaults >> On Open >> Display Xpage instead >> mailSendTest), then this also works for the XPinc version. And if the recipient then clicks on the doc link the originating document of course opens in XPinc mode as well.
Remark:
I need to save the originating doc at least once otherwise the appended doc link might not be usable for the recipients; could this have been the reason why Fredrik's answer didn't work for you?
Hope this helps. If this is working for you please accept Fredrik's answer.
Update:
Changed some variable names in my code example to clarify things
I simply use these two lines:
var url =
#Left(facesContext.getExternalContext().getRequest().getRequestURL(),"newDocument.xsp")+"newDocument.xsp?documentId="+document1.getDocument().getUniversalID()+"&action=openDocument";
rtitem.appendText(url);
where newDocument.xsp is the form xsp of the document, rtitem is the rich text field of the mail. That will add the whole link to your document.

display CurrentUserName on list form web part

I have a requirement to display the currently logged in user on a newItem list form the user is filling out- I have a people picker control which I know I can convert to the Rich Text format to display the current user.
However, I am having trouble getting the current user. I took a look at how SP did it, but found that they also had "Welcome " embedded into their code, so I cannot just re-use it.
Then I found this resource that showed me how to get the logged on user from the server variable. But I have no idea to display it on the form, so I don't even know if it got what I was actually looking for!
While I was poking around the code for the page, I found that I'd already had the following parameter
<ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
<xsl:param name="UserID" />
which looked like it might do the trick, but again.... I can't figure out how to display the value of it on the webpart form- so I don't even know.
How can I display the value of a parameter on webpart page so that I can verify that it is what I am looking for?
Thanks!
You can use <xsl:value-of select="$UserID" /> to display current user name.

Sharepoint item updating event - cancel event back to editform page?

I have an event receiver for a content type to validate some data in the ItemUpdating event. If I cancel the event (some of the data isn't valid for example), I set the properties cancel to true:
properties.Cancel = true;
properties.ErrorMessage = "...";
SharePoint cancels the updating event ok, but shows the standard SharePoint error page (with the specified message). Only problem is, I've got a complaint that this isn't actually very useful - we should return to the EditForm page so the details can be updated.
Has anyone done this, is there an easy way? The only suggestion I've had is that I can implement my own error page, but that's sounding quite a heavy solution to a (theoretically) simple process.
You could try to output HTML code (which includes javascript as well) in the ErrorMessage. BUT even if you do, the problem is that you have no safe way back to the data the user has entered. Either you make a HTTP/301 redirect and then it's a new page load, or you make the client go history.back() with JavaScript and then the browser may reload the page.
The official way of doing this is that you create a list definition and customize the list template. Then you edit the edit form template and include as many ASP.Net validator controls as needed. Then, implement the server side logic as you need. This article explains the technique: http://msdn.microsoft.com/en-us/library/aa543922.aspx
EDIT: To attach a custom control for editing of a specific contenttype, you add an XmlDocuments section to your ContentType definition. For instance, like this
<ContentType
..........
<XmlDocuments>
<XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
<FormTemplates xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
<Display>ContentTypeName_DispForm</Display>
<Edit>ContentTypeName_EditForm</Edit>
<New>ContentTypeName_NewForm</New>
</FormTemplates>
</XmlDocument>
</XmlDocuments>
.......
Then you create your own yoursolution_controltemplates.ascx file, which contains as well such blocks:"
<SharePoint:RenderingTemplate ID="ContentTypeName_DispForm" runat="server">
<Template>
<!-- put whatever controls you need here, we typically create a
separate custom control which implements everything-->
</Template>
</SharePoint:RenderingTemplate>
You can try to redirect using CopyUtil : http://weblogs.asp.net/jan/archive/2008/02/26/copyutil-aspx-a-little-sharepoint-gem.aspx
link = "http://yoursite/_layouts/CopyUtil.aspx?Use=id&Action=dispform&ItemId=X&ListId=X&WebId=X&SiteId=X";
Page.Response.Redirect(link)
maybe this will work

Resources