Email form when an item is submitted - nintex-workflow

I am new to Nintex. How can I send the form user submitted in the email after he/she hits submit button?
I tried to to create a workflow, but it just sends email without content.

You can include the item URL in the body your email - the link will take them back to the item/form that they just submitted
or
you can use the lookups to insert the fields on your email

/*
* This function sends an email when a specific Google Sheets column is edited
* The spreadsheets triggers must be set to onEdit for this function to work
*/
function sendNotification() {
//var ss = SpreadsheetApp.openById('1N6dqSXs8hdhCi1vrOGT7I7tD2yDMtgK7BSddMPqmuo0');
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
//Get Active cell
var mycell = ss.getActiveSelection();
var cellcol = mycell.getColumn();
var cellrow = mycell.getRow();
//Define Notification Details for vars
var recipients = "joseph#XXXXX.com,jmang#XXXXX.com";
var recipients1 = "joseph2#XXXXX.com"
var subject = "NEW SENSITIVE DATA REQUEST REQUIRES APPROVAL";
var subject1 = "ALERT: SENSITIVE DATA REQUEST";
var body = ss.getName() + " has been updated. Visit " + ss.getUrl() + " to view the changes.";
//Check to see which column will trigger the email - this script sends an email to "var recipients" if
//column 5 is updated and sends and email to "var recipients1" when colum 7 is updated.
if (cellcol == 5) {
//Send the Email to recipients defined in "var recipients"
MailApp.sendEmail(recipients, subject, body);
}
if (cellcol == 7) {
//Send the Email to recipients defined in "var recipients1"
MailApp.sendEmail(recipients1, subject1, body);
}
//End sendNotification
}

Related

Anchor tags are not showing up in the document

Anchor tags are not showing up in the document
We have a 14 page document where the users will have to sign at the end of the Document on the field specified. The Document pdf looks like '
Where near the By field I have /s1/ tag which is invisible. And also in the Docusign custom button Controller I have the code like
................
Attachment att = [Select id,Name,Body,parentid from Attachment where parentid =: OppLst.id order by createddate DESC LIMIT 1 ];
DocuSignTK.Document document = new DocuSignTK.Document();
document.ID = 1;
document.Name = 'Quote Document';
document.FileExtension = 'html';
document.pdfBytes = EncodingUtil.base64Encode(attach.Body);
DocuSignTK.Recipient recipient = new DocuSignTK.Recipient();
recipient.Email = 'dh#gmail.com';
recipient.UserName = 'Dh';
recipient.ID = 1;
recipient.Type_x = 'Signer';
recipient.RoutingOrder = 1;
// The signer tab...
DocuSignTK.Tab signHereTab = new DocuSignTK.Tab();
signHereTab.Type_x = 'SignHere';
signHereTab.AnchorTabItem = new DocuSignTK.AnchorTab();
signHereTab.AnchorTabItem.AnchorTabString = 'signer1sig';
signHereTab.AnchorTabItem.XOffset = 8;
signHereTab.RecipientID = 1;
signHereTab.Name = 'Please sign here';
signHereTab.ScaleValue = 1;
signHereTab.TabLabel = 'signer1sig';
// The dateSigned tab
DocuSignTK.Tab dateSignedTab = new DocuSignTK.Tab();
dateSignedTab.Type_x = 'DateSigned';
dateSignedTab.AnchorTabItem = new DocuSignTK.AnchorTab();
dateSignedTab.AnchorTabItem.AnchorTabString = 'signer1date';
dateSignedTab.AnchorTabItem.YOffset = -6;
dateSignedTab.RecipientID = 1;
dateSignedTab.Name = 'Date Signed';
dateSignedTab.TabLabel = 'date_signed';
// Create an envelope and fill it in
DocuSignTK.Envelope envelope = new DocuSignTK.Envelope();
envelope.Subject = 'Please sign the Quote Document';
envelope.AccountId = account_id;
envelope.Tabs = new DocuSignTK.ArrayOfTab();
envelope.Tabs.Tab = new DocuSignTK.Tab[2];
envelope.Tabs.Tab.add(signHereTab);
envelope.Tabs.Tab.add(dateSignedTab);
envelope.Recipients = new DocuSignTK.ArrayOfRecipient();
envelope.Recipients.Recipient = new DocuSignTK.Recipient[1];
envelope.Recipients.Recipient.add(recipient);
envelope.Documents = new DocuSignTK.ArrayOfDocument();
envelope.Documents.Document = new DocuSignTK.Document[1];
envelope.Documents.Document.add(document);
if (String.isNotBlank(email_message))
{
envelope.EmailBlurb = email_message;
}
In the Docusign email it doesn't show anything
How to make the tags available so it is easy for the user to click and Sign.
the string that you use in your document to "anchor" the tabs should be the same that you specify in your tab AnchorTabString property.
You mentioned that the document has an invisible /s1/ tag in the text, but it looks like in your code you are setting a different value for the anchor string:
signHereTab.AnchorTabItem.AnchorTabString = 'signer1sig';
if you update this value to match the /s1/ value in your document it should work.
One way to troubleshoot this would be to log into your DocuSign account, create a new envelope using the document above, add a recipient and go to the tagger page.
Once in the tagger page you can use the "auto-place" feature, which is the same as the anchor strings, to test that the string that you want to use as an anchor can be found in the document.
Once you verify that you have the right string, you could use that string in your API call and things should work.
How to use the auto-place feature:
https://support.docusign.com/en/guides/AutoPlace-New-DocuSign-Experience

Unable to send attachment - Salesforce Docusign API

I am trying to send attachment (record has one attachment) in opportunity record via Apex and Docusign "CreateAndSendEnvelope" API.
But I am getting this error "The DocuSign EnvelopeId:Exception - System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: An Error Occurred during anchor tag processing. Invalid document faultcode=soap:Client faultactor=https://demo.docusign.net/api/3.0/dsapi.asmx"
Below is the piece of code used.
// Render the contract
System.debug('Rendering the contract');
PageReference pageRef = new PageReference('/apex/RenderContract');
pageRef.getParameters().put('id',contract.Id);
//Blob pdfBlob = pageRef.getContent();
Attachment att = [SELECT Id, Name, Body, ContentType FROM Attachment WHERE Parentid = :contract.Id LIMIT 1];
Blob pdfBlob = att.Body;
// Document
DocuSignAPI.Document document = new DocuSignAPI.Document();
document.ID = 1;
document.pdfBytes = EncodingUtil.base64Encode(pdfBlob);
document.Name = 'Contract';
document.FileExtension = 'pdf';
envelope.Documents = new DocuSignAPI.ArrayOfDocument();
envelope.Documents.Document = new DocuSignAPI.Document[1];
envelope.Documents.Document[0] = document;
// Recipient
System.debug('getting the contact');
Contact contact = [SELECT email, FirstName, LastName
from Contact where id = :contract.CustomerSignedId];
DocuSignAPI.Recipient recipient = new DocuSignAPI.Recipient();
recipient.ID = 1;
recipient.Type_x = 'Signer';
recipient.RoutingOrder = 1;
recipient.Email = contact.Email;
recipient.UserName = contact.FirstName + ' ' + contact.LastName;
// This setting seems required or you see the error:
// "The string '' is not a valid Boolean value.
// at System.Xml.XmlConvert.ToBoolean(String s)"
recipient.RequireIDLookup = false;
envelope.Recipients = new DocuSignAPI.ArrayOfRecipient();
envelope.Recipients.Recipient = new DocuSignAPI.Recipient[1];
envelope.Recipients.Recipient[0] = recipient;
// Tab
DocuSignAPI.Tab tab1 = new DocuSignAPI.Tab();
tab1.Type_x = 'SignHere';
tab1.RecipientID = 1;
tab1.DocumentID = 1;
tab1.AnchorTabItem = new DocuSignAPI.AnchorTab();
tab1.AnchorTabItem.AnchorTabString = 'By:';
DocuSignAPI.Tab tab2 = new DocuSignAPI.Tab();
tab2.Type_x = 'DateSigned';
tab2.RecipientID = 1;
tab2.DocumentID = 1;
tab2.AnchorTabItem = new DocuSignAPI.AnchorTab();
tab2.AnchorTabItem.AnchorTabString = 'Date Signed:';
envelope.Tabs = new DocuSignAPI.ArrayOfTab();
envelope.Tabs.Tab = new DocuSignAPI.Tab[2];
envelope.Tabs.Tab[0] = tab1;
envelope.Tabs.Tab[1] = tab2;
System.debug('Calling the API');
try {
DocuSignAPI.EnvelopeStatus es
= dsApiSend.CreateAndSendEnvelope(envelope);
envelopeId = es.EnvelopeID;
} catch ( CalloutException e) {
System.debug('Exception - ' + e );
envelopeId = 'Exception - ' + e;
}
Any ideas how to overcome this error?
Thanks.
The Original Poster's (OP's) comment is
it worked fine on rendering the whole record to pdf...but now i tried sending attachments only instead of whole record.. i started to get this error.
So my guess is that the envelope request has a document problem.
Best way to debug: see what is being sent to the DocuSign platform.
Try the beta API logger or the regular logger. Then add the log to your question by editing your question.
This problem came across me with same error .
" An Error Occurred during anchor tag processing. Invalid document faultcode=soap:Client faultactor=https://demo.docusign.net/api/3.0/dsapi.asmx "
you need to replace anchor tab string with desired string given in your attached document where signature is required.
Replace :
tab1.AnchorTabItem.AnchorTabString = 'By:';
tab2.AnchorTabItem.AnchorTabString = 'Date Signed:';
To :
tab1.AnchorTabItem.AnchorTabString = 'Signature label in your document';
tab2.AnchorTabItem.AnchorTabString = 'Signature label in your document';

Add Account attachment to Chatter Post Automatically

I have need to add account attachments in Salesforce to the account chatter feed automatically. I've got the following code, which adds a chatter post for every object, not just account attachments, how can I make it specific to accounts? Or how can I make it specific to a certain file name?
trigger AttachFileToAccountFeed on Attachment (before insert) {
ID accountId;
list<FeedItem> listOfFeedFiles = new List<FeedItem>();
if(Trigger.isBefore){
for(Attachment attachment : trigger.new){
string checkIfAccount = string.valueof(attachment.description);
{
//Adding a Content post
accountId = attachment.ParentId;
FeedItem post = new FeedItem();
post.ParentId = accountId; //eg. Opportunity id, custom object id..
post.Body = 'Attachment added';
post.Type = 'ContentPost';
post.ContentData = attachment.body;
post.ContentFileName = attachment.Name;
post.Title = attachment.Name;
listOfFeedFiles.add(post);
}
}
}
if(listOfFeedFiles!=null){
insert listOfFeedFiles;
}
}
Here's what I ended up using:
trigger AttachFileToAccountFeed on Attachment (before insert) {
ID accountId;
list<FeedItem> listOfFeedFiles = new List<FeedItem>();
if(Trigger.isBefore){
for(Attachment attachment : trigger.new) {
// ensure the Id is an Account Id
if(attachment.ParentId.getSObjectType() != Account.SObjectType)
continue;
// ensure file contains Signed Authorization in File Name
if(attachment.Name.contains('Signed Authorization')) {
//Adding a Content post
accountId = attachment.ParentId;
FeedItem post = new FeedItem();
post.ParentId = accountId;
post.Body = 'Attachment added';
post.Type = 'ContentPost';
post.ContentData = attachment.body;
post.ContentFileName = attachment.Name;
post.Title = attachment.Name;
listOfFeedFiles.add(post);
}
}
}
if(listOfFeedFiles!=null){
insert listOfFeedFiles;
}
}

Automatically creating entry in Outlook calendar using the Exchange API

I am using the Exchange API to send appointment requests from any email address. Below is my code:
ExchangeService exService = new ExchangeService(ExchangeVersion.Exchange2013);
exService.Url = new Uri("exchange URL");
exService.Credentials = new WebCredentials("userID", "password");
Appointment appointment = new Appointment(exService);
appointment.Subject = "Test Subject";
appointment.Body = "test body";
appointment.Location = "Location";
appointment.Start = <Meeting start time>;
appointment.End = <Meeting end time>
appointment.RequiredAttendees.Add("abc#xyz.com");
appointment.Save(SendInvitationsMode.SendOnlyToAll);
This code is working fine: it sends an invitation email to the attendee.
What I want to know is, is it possible to make an entry into the attendee's Outlook calendar directly, without any invitation email or any approval from the attendee?
No, but if you impersonate the Attendee you can then accept the invitation on their behalf. See:
https://msdn.microsoft.com/en-us/library/office/dd633680(v=exchg.80).aspx
https://msdn.microsoft.com/en-us/library/office/dd633648(v=exchg.80).aspx
Below code might help you.
ExchangeService exService = new ExchangeService(ExchangeVersion.Exchange2013);
exService.Url = new Uri("exchange URL");
exService.Credentials = new WebCredentials("userID", "password");
Collection<Appointment> Meetings = new Collection<Appointment>();
Appointment appointment = new Appointment(exService);
appointment.Subject = "Test Subject";
appointment.Body = "test body";
appointment.Location = "Location";
appointment.Start = <Meeting start time>;
appointment.End = <Meeting end time>
appointment.RequiredAttendees.Add("abc#xyz.com");
Meetings.add(appointment)
ServiceResponseCollection<ServiceResponse> responses = service.CreateItems(Meetings,WellKnownFolderName.Calendar,MessageDisposition.SendOnly,SendInvitationsMode.SendToNone);

url sharepoint list camlquery

I'm trying to collect my url and the description of the url stored in a column of a list from sharepoint and i don't know how to collect the URL value.
This is my code :
var queryResultSaleListItems = clientContext.LoadQuery(listData);
clientContext.ExecuteQuery();
//Read the Data into the Object
var TipsList = from Tips in queryResultSaleListItems
select Tips;
ObservableCollection<Tips> colTips = new ObservableCollection<Tips>();
//Read Every List Item and Display Data into the DataGrid
foreach (SPSClient.ListItem item in TipsList)
{
var tips = new Tips();
tips.TitleTip = item.FieldValues.Values.ElementAt(1).ToString();
tips.App = item.FieldValues.Values.ElementAt(4).ToString();
//should collect the url
tips.URL = item.FieldValues.Values.ElementAt(5).ToString();
//should collect the description of the url
tips.URLdesc = item.FieldValues.Values.ElementAt(5).ToString();
colTips.Add(tips);
}
ListboxTips.DataContext = colTips;
In my expression its >
((Microsoft.SharePoint.Client.FieldUrlValue)(item.FieldValues.Values.ElementAt(5))).Url
((Microsoft.SharePoint.Client.FieldUrlValue)(item.FieldValues.Values.ElementAt(5))).Description
Thanks for your help,
Use FieldUrlValue for getting hyperlink field in Client Object Model.
Use Following Code:
string server = "siteURL";
var ctx = new ClientContext(server);
var web = ctx.Web;
var list = web.Lists.GetByTitle("CustomList");
var listItemCollection = list.GetItems(CamlQuery.CreateAllItemsQuery());
ctx.Load(listItemCollection);
ctx.ExecuteQuery();
foreach (Microsoft.SharePoint.Client.ListItem listItem in listItemCollection)
{
string acturlURL = ((FieldUrlValue)(listItem["URL"])).Url.ToString(); // get the Hyperlink field URL value
string actdesc = ((FieldUrlValue)(listItem["URL"])).Description.ToString(); // get the Hyperlink field Description value
}

Resources