Sending via the Quote - salesforce

I have the following custom code that I am placing on the Opportunity object. I want to click this custom Send With DocuSign button and have it load the most recent's quote's attachments. My code is unfortunately not working. Is there something I am missing and need to add?
{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")}
var rc = GetRelContentIDs("{!Opportunity.Id}");
var RQD = DSGetPageIDFromHref();
var LA = 1;
window.location.href = "/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Opportunity.Id}&RQD="+RQD+"&LA="+LA+"&RC="+rc;

Are you getting a specific error message?
The second example from the documentation works for me:
https://www.docusign.com/sites/default/files/DocuSignForSalesforceReleaseNotesv4.1.17.pdf#page=2
{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")}
var sourceId = DSGetPageIDFromHref();
var rc = GetRelContentIDs(sourceId);
var LA = 1;
window.location.href =
"/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID="+sourceId+"&rc=
"+rc+"&RQD=" + sourceId+"&LA="+LA;
I believe the issue you are running into is when you are adding the merge fields for the SourceID and RC parameter.

Related

Unable to access all ItemResponses in a FormResponse

I have a strange error occurring in an Apps Script function attached to a Google Form.
I call the responses, then list them in an array. The log shows that there are 6 items in the array, which matches the six form questions:
[18-05-08 00:13:31:900 AEST] [ItemResponse, ItemResponse, ItemResponse, ItemResponse, ItemResponse, ItemResponse]
When I call the first two, it works just fine. Any more and it bugs out and says undefined.
// Open a form by ID and log the responses to each question.
var form = FormApp.getActiveForm();
var formResponses = form.getResponses();
for (var i = 0; i < formResponses.length; i++) {
var formResponse = formResponses[i];
var editUrl = String(formResponse.getEditResponseUrl());
var theResponseId = formResponses.indexOf(form);
var itemResponses = formResponse.getItemResponses();
var timestamp = formResponse.getTimestamp();
var firstName = itemResponses[0].getResponse();
var lastName = itemResponses[1].getResponse();
Logger.log(itemResponses); // Log shows there are 6 objects in the array. Matching the amount of Form Questions.
// If I try to use these variables below, it doesn't work and the script 'breaks' at this point.
//var number = itemResponses[2].getResponse();
//var email = itemResponses[3].getResponse();
//var firstName2 = itemResponses[4].getResponse();
//var comments = itemResponses[5].getResponse();
}
Note: I have tried FormApp.openById('id'); to see if maybe getting the active form was a problem. This didn't help.
This is because some answers were submitted to a 2 question form. If you submitted some responses prior to updating the form, the answers to these new questions will be "undefined".

google apps script: setValues from array, taken from html form onSubmit in google sheets

In Google Sheets, I have a sidebar using html, with a form which runs processForm(this) upon submission. The form was created based on the headings in the sheet, which is why I am using the headings to retrieve the values from the form. The code seems to work fine until I try to use setValues(). There is no error, but nothing seems to happen at that line. Please let me know what I might be doing wrong. Thanks.
function processForm(formObject) {
var headers = getHeaders();
var newRow = [];
for (var i = 0; i < headers.length; i++) {
newRow.push(formObject["" + headers[i]]); // TODO: convert objects to appropriate formats
}
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange(parseInt(formObject.row)+1, 1, 1, headers.length)
Logger.log(JSON.stringify(newRow)); // example output: ["John","Smith","male","6615554109","","example_email#yahoo.com"]
range.setValues(newRow); // values not getting set
}
Change last line:
range.setValues([newRow]);
(thanks for the solution, Serge insas!)

Implementing piwik.js custom event sending to service

Is it possible to use Piwik for tracking but to process and send events to custom service instead of Piwik one?
Also make POST instead of GET requests to service?
Yes, something like that is possible. Piwik has setCustomRequestProcessing function. That function lets you edit the tracking request before it is sent.
As far as POST, you can get query parameters from piwiks tracking request. Something like this:
var getQueryParameters = function (hash) {
var split = hash.split('&');
var obj = {};
for (var i = 0; i < split.length; i++) {
var kv = split[i].split('=');
obj[kv[0]] = decodeURIComponent(kv[1] ? kv[1].replace(/\+/g, ' ') : kv[1]);
}
return obj;
};

Passing an Array with Objects to another function in GAS

Just to give you a little background on my question:
I am creating a form in Google App Script using the UI Services and I am storing specific calendar events in a dataArray. So the event object is stored in the array. I want to pass this array to the submit function but can't figure out how to go about this because :
I can't add it as a callback element (because it isn't a widget)
I can't store the event object in a widget (i.e. a listbox, etc) and then add that widget as a callback element.
Here is a brief sample of what I am trying to do:
var cal= CalendarApp.getDefaultCalendar();
var event= cal.getEvents(new Date("June 16, 2013 PST"),
new Date("July 22, 2013 PST"));
var specific = new Array;
for( var j=0; j<event.length;j++){
specific.push(event[j]);
//This stores the events in the specific variable
//I want to send this variable (w/ the data) to another function on submit
I would appreciate any suggestions you can lend me.
Thanks!
As a complement to the answer I gave in the comments : "you could also simply store the id and while you read the events again using the same start/end time you can check if an event correspond to the saved ID in a loop... if a match is found with the right ID you are sure it's the right event"
Here is a piece of code I use to modify/update/delete calendar events using their ID as reference. This code is used to delete specific events selected from the spreadsheet, the code to modify events is roughly the same, at least it uses the same ID checking.
...
var cal = CalendarApp.openByName(calName);
if (cal) {
var events = cal.getEvents(new Date(date_deb), new Date(date_fin),{max: 4000}); // stocke tt ds une variable array
var sel= sh.getRange(6,1,sh.getLastRow()-5, 10).getValues();// read data in the SS
for(e=0;e<events.length;++e){
var delFlag = false;
var ID = events[e].getId();
for(n=0;n<sel.length;++n){
if ((sel[n][8] == "x"||sel[n][8] == "X")&&sel[n][9]==ID){ // the ID here is stored in the spreadsheet in column J and I use a 'X' marker to select which event should be deleted
delFlag = true;
sh.getRange(n+6,9,1,2).setBackgroundColor('#ff5500');
SpreadsheetApp.flush();
Logger.log('FLAG '+ e);
break;
}
}
if(delFlag){
try{
var toDelete = events[e].deleteEvent();
++todel;
delFlag = false;
Logger.log('event deleted : '+sel[n][1]);
}catch(Err){Logger.log('Event from a serie already deleted from another occurence')}
}
}
}
var msg = todel + " événement(s) effacé(s) dans l'Agenda '"+calName+"'";
ss.toast("Effacement terminé", msg, 3);
...

SqlCacheDependecy command notification not working

I been trying to get sqlcachedependecy working, but it doesn't appear to work
I got the proper settings in my web.config and also global.asa, however when I run this query and the changes are made to the database from either with in or outside the web site the cached objects are not updated please someone help? I know its not because this query is querying a view, because I tested this using straight SqlDependecy and the notification works fine.
public IQueryable<VictoryList> GetVictoryList()
{
string cacheKey = HttpContext.Current.User.Identity.Name + "victoryCacheKey";
IQueryable<VictoryList> cachednews = (IQueryable<VictoryList>)HttpContext.Current.Cache.Get(cacheKey);
if (cachednews == null)
{
var results = from v in _datacontext.ViewVictoryLists
orderby _datacontext.GetNewId()
select new VictoryList
{
MemberID = v.MemberID,
Username = v.Aspnetusername,
Location = v.Location,
DaimokuGoal = v.DaimokuGoal,
PreviewImageID = v.PreviewImageID,
TotalDaimoku = v.TotalDaimoku,
TotalDeterminations = v.TotalDeterminations,
DeterminationID = v.DeterminationID,
DeterminationName = v.DeterminationName
};
results = results.ToList().AsQueryable();
SqlCacheDependencyAdmin.EnableNotifications(_datacontext.Connection.ConnectionString);
SqlCacheDependency dependency =
new SqlCacheDependency(_datacontext.GetCommand(results) as SqlCommand);
HttpContext.Current.Cache.Insert(cacheKey, results, dependency);
return results;
}
return cachednews;
}
According to the stated Limitations for creating a query for notification, listed at msdn...
The statement must not reference a view.

Resources