Yesterday I updated the DocuSign Template ID on a previously successful custom button and began receiving the error message below. So I changed the Template ID back to the original value and continue to receive the same error.
Thoughts on what might be going on?
Error Message:
"Apex CPU time limit exceeded Error is in expression '{!CreateEnvelopeRecord}' in component in page dsfs:docusign_createenvelope: (dsfs)"
Button Code:
{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")}
//********* Option Declarations (Do not modify )*********//
var RC = '';var RSL='';var RSRO='';var RROS='';var CCRM='';var CCTM='';var CCNM='';var CRCL=''; var CRL='';var OCO='';var DST='';var LA='';var CEM='';var CES='';var STB='';var SSB='';var SES='';var SEM='';var SRS='';var SCS ='';var RES='';
//*************************************************//
// Modify individual options here:
// DocuSign Template ID (default no template)
DST = '5FA61634-AA13-4BCB-B02A-521B19C3DFB4'; //Ex: '67870A79-A0B5-4596-8AC1-CC7CC1EA01EB'
// Load Attachments (default on)
LA = ''; //Ex: '0'
// Custom Email Message (default in config)
CEM = 'Thank you for doing business with XOJet, here is the agreement for your signature.' ; //Ex: 'Envelope sent by [FirstName] [LastName] ([Email])!'
// Custom Email Subject (default in config)
CES = 'XOJet agreement for signature'; //Ex: 'Re: Opportunity Name: {!Opportunity.Name}'
// Show Tag Button (default in config)
STB = ''; //Ex: '1'
// Show Send Button (default in config)
SSB = ''; //Ex: '1'
// Show Email Message (default in config)
SEM = ''; //Ex: '1'
// Show Reminder/Expire (default in config)
SRS = ''; //Ex: '1'
// Show Chatter (default in config)
SCS = ''; //Ex: '1'
// Reminder and Expiration Settings
RES = ''; //Ex: '0,1,2,0,120,3'
//********* Page Callout (Do not modify) *********//
window.location.href = "/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Opportunity.Id}&RC="+RC+"&RSL="+RSL+"&RSRO="+RSRO+"&RROS="+RROS+"&CCRM="+CCRM+"&CCTM="+CCTM+"&CRCL="+CRCL+"&CRL="+CRL+"&OCO="+OCO+"&DST="+DST+"&CCNM="+CCNM+"&LA="+LA+"&CEM="+CEM+"&CES="+CES+"&SRS="+SRS+"&STB="+STB+"&SSB="+SSB+"&SES="+SES+"&SEM="+SEM+"&SRS="+SRS+"&SCS="+SCS+"&RES="+RES;
//*******************************************//
Is this a managed package, or your own page? The page is taking too long to run and exceeds the governor limit (from Salesforce). If it is your own page then check your code (specifically look for loops to eliminate).
If it is managed you will probably need to file a ticket.
Salesforce limits doc:
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm
I'm still not sure what's going on, but I may have a new clue. I found the code below in another discussion at DocuSign for Salesforce.com
What's curious is that if I use the code below I will no longer get the "Time Limit" error. HOWEVER, it breaks when I replace the Custom Envelop ID to the one I"m using. Same "Time Limit" error.
I downloaded the XML again or the template to double-check the ID and it's correct. I know virtually zip about code and an API's so I'm baffled.
Thoughts?
{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")}
//********* Option Declarations (Do not modify )*********//
var RC = '';var RSL='';var RSRO='';var RROS='';var CCRM='';var CCTM='';var CCNM='';var CRCL=''; var CRL='';var OCO='';var DST='';var LA='';var CEM='';var CES='';var STB='';var SSB='';var SES='';var SEM='';var SRS='';var SCS ='';var RES='';
//*************************************************//
//DocuSign Template
var DST='';
//Adding Notes & Attachments
var LA='1';
//Custom Recipient List
var CRL='Email~johnsemail#outlook.com;FirstName~user;LastName~1;Role~Signer 1;RoutingOrder~1,Email~janesemail#outlook.com;LastName~user2;Role~Signer 2;RoutingOrder~2,LoadDefaultContacts~1';
//Custom Contact Role Map
var CCRM='Signer 1~Customer;Signer 2~SalesRep';
//Custom Contact Type Map
var CCTM='Signer 1~Signer;Signer 2~Signer';
//Custom Email Subject
var CES='Please eSign Vocus Sales Agreement';
//Custom Email Message
var CEM='I am sending you this request for your electronic signature, please review and electronically sign by following the link below.';
//Custom Envelop from Docusign
var DST = '7C350ABB-74F9-463E-96E3-49153AA25607';
//********* Page Callout (Do not modify) *********//
window.location.href ="/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Opportunity.Id}&RC="+RC+"&RSL="+RSL+"&RSRO="+RSRO+"&RROS="+RROS+"&CCRM="+CCRM+"&CCTM="+CCTM+"&CRCL="+CRCL+"&CRL="+CRL+"&OCO="+OCO+"&DST="+DST+"&CCNM="+CCNM+"&LA="+LA+"&CEM="+CEM+"&CES="+CES+"&SRS="+SRS+"&STB="+STB+"&SSB="+SSB+"&SES="+SES+"&SEM="+SEM+"&SRS="+SRS+"&SCS="+SCS+"&RES="+RES;
//*******************************************//
Related
I have an admin account to create Online meetings of Graph API. Suppose I want to create online meetings for others to be the organizer, how should I do it? I do not see any parameter for that while creating the meeting.
You can request /me/onlineMeetings/createOrGetAPI, and then add the organizer to the request body.
please see: here
Try this:
var client = new RestClient("https://graph.microsoft.com/v1.0/me/onlineMeetings");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer "+token);
request.AddHeader("accept-language", "en");
request.AddHeader("accept", "application/json");
request.AddParameter("application/json", "{\"startDateTime\": \"2020-09-
28T19:30:34.2444915-07:00\",\n\"endDateTime\": \"2020-09-
28T20:00:34.2464912-07:00\",\"subject\": \"User Token Meeting\"}",
ParameterType.RequestBody);
var response = client.Execute(request);
To retrieve the token:
var client = new RestClient("https://login.microsoftonline.com/{tenant-
Id}/oauth2/v2.0/token");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddHeader("grant_type", "password");
request.AddParameter("application/x-www-form-urlencoded",
"grant_type=password&client_id={client-Id}&client_secret={client-
secret}&scope={scopeurl}&userName={username}&password={password}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
var json = response`.`Content;
var JSONObject = JObject.Parse(json);
var token = (string)JSONObject["access_token"];
I'm trying to use the paypal-cordova-plugin to integrate paiement on my mobile app. But the instructions I am following are asking for sandbox id and production id but I have no idea where to find them in paypal. Can someone help me on this ?
This is the place where they are asked
angular.module('app')
.constant("shopSettings", (function () {
return {
payPalSandboxId: "Aar8HZzvc5NztVWodTBpOiOod9wWrBDrJUjyvRr4WsxcCD28xYig7oecfYsqxQUDu5QHptPpSALirxZD",
payPalProductionId : "production id here",
payPalEnv: "PayPalEnvironmentSandbo", // for testing production for production
payPalShopName : "SenPass",
payPalMerchantPrivacyPolicyURL : "url to policy",
payPalMerchantUserAgreementURL : "url to user agreement"
}
})());
This is the link I'm following : http://ionicandroidlearning.blogspot.fr/2015/11/ionic-paypal-integration.html
First you need to create an account on paypal developers.
Then inside the dashboard create a new application (REST API apps).
When you create the new app, Paypal will generate a sandbox account and a client id for you.
Add the code (example):
var configuration=function () {
var configOptions = {
merchantName: "Some name you have specified",
merchantPrivacyPolicyURL: "http://yourserver/privacypolicy",
merchantUserAgreementURL: "http://yourserver/agreement",
languageOrLocale: "en_US"
};
// for more options see paypal-mobile-js-helper.js
var _config = new PayPalConfiguration( configOptions );
return _config;
}
var onPrepareRender = function(){
$log.info(" ======= onPrepareRender ==========");
}
var onPayPalMobileInit = function(){
var payPalConfig = configuration();
PayPalMobile.prepareToRender("PayPalEnvironmentSandbox", payPalConfig, onPrepareRender);
deferred.resolve( payPalConfig );
}
var clientIDs = {
"PayPalEnvironmentProduction": '', //leave it blank
"PayPalEnvironmentSandbox": 'your sandbox id'
};
PayPalMobile.init(clientIDs, onPayPalMobileInit);
to retrive PayPal Sandobx keys try to go here:
https://developer.paypal.com/developer/accounts/
click on your generated account for testing (in the table) and then on Profile ...it open a modal with some tabs .. choose the API Credential tab
Hope it can help you
I am trying to get the emails from gmail using https://www.googleapis.com/auth/gmail.readonly/?access_token='fdrt654vfdgfe6545But in response I am getting gmail.readonlyBut the System.HttpResponse[Status=OK, StatusCode=200] is fine. Can any guide me is there anything I am missing out.
This I how I requested got auth but in the response I received access token
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/client:plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/client:plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
var AuthStates = {google: null};
function signinCallback(authResult) {
if (authResult['status']['signed_in']) {
// Update the app to reflect a signed in user
// Hide the sign-in button now that the user is authorized, for example:
document.getElementById('signinButton').setAttribute('style', 'display: none');
//alert(authResult['code']);
console.log('code state: ' + authResult['code']);
//console.log('authResult : ' + authResult[]);
AuthStates.google = authResult;
console.log('authResult 1 : ' + authResult['status']['method']);
console.log('auth Result : ' + authResult['id_token']);
//{!access_token} = authResult['access_token'];
//{!code} = authResult['code'];
connection(authResult['access_token'], authResult['code']);
} else {
// Update the app to reflect a signed out user
// Possible error values:
// "user_signed_out" - User is signed-out
// "access_denied" - User denied access to your app
// "immediate_failed" - Could not automatically log in the user
console.log('Sign-in state: ' + authResult['error']);
}
}
</script>
<apex:outputPanel >
<span id="signinButton">
<span
class="g-signin"
data-callback="signinCallback"
data-clientid="clientid"
data-cookiepolicy="single_host_origin"
data-scope="https://www.googleapis.com/auth/gmail.readonly"
data-response_type="code"
data-redirect_uri="http://test-on.ap1.visual.force.com/apex/Gmail_inbox">
</span>
</span>
<apex:form >
So as i got my access token from my request I can go directly for getting all information related to the logedin user. As I am getting all the information regarding the user I am trying to get all the emails related to him. Is I am doing right or I am wrong any place. I am very new with api and web service trying to learn. please do help me put out.
You're actually making an HTTP GET call to that URL ( https://www.googleapis.com/auth/gmail.readonly/?access_token= ...)? Isn't that just the auth scope identifier?
Once you have a valid Oauth2 token you can set in the Auth header then you can make HTTP requests to the API. For example, to list messages see:
https://developers.google.com/gmail/api/v1/reference/users/messages/list
That has the URL to access (GET https://www.googleapis.com/gmail/v1/users/me/messages ) then once you have the message IDs you can get the messages individually following: https://developers.google.com/gmail/api/v1/reference/users/messages/get (e.g. GET https://www.googleapis.com/gmail/v1/users/me/messages/ ).
Usually there are good client libraries for the Google APIs. Not sure if that works for you, but see, for example:
https://developers.google.com/gmail/api/downloads
I have 2 users. I need to send the envelope to User 1 to sign. Once user 1 has signed the document, User 2 needs to get the envelope to sign the document.
I have written a Custom button on a Custom object where I am passing the envelop ID and Passing the users to whom the envelope will be sent along with the routingOrder, but the envelope is received by both the users. I was not able to find a proper document that could help me resolve the issue. Piece of javascript:
{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")}
//********* Option Declarations (Do not modify )*********//
var RC = '';var RSL='';var RSRO='';var RROS='';var CCRM='';var CCTM='';var CCNM='';var CRCL=''; var CRL='';var OCO='';var DST='';var LA='';var CEM='';var CES='';var STB='';var SSB='';var SES='';var SEM='';var SRS='';var SCS ='';var RES='';
//*************************************************//
//DocuSign Template
var DST='';
//Adding Notes & Attachments
var LA='1';
//Custom Recipient List
var CRL='Email~test_1#gmail.com;FirstName~user;LastName~1;Role~Signer 1;RoutingOrder~1,Email~test_2#gmail.com;LastName~user2;Role~Signer 2;RoutingOrder~2,LoadDefaultContacts~1';
//Custom Contact Role Map
var CCRM='Signer 1~Signer 1;Signer 2~Signer 2';
//Custom Contact Type Map
var CCTM='Signer 1~Signer 1;Signer 2~Signer 2';
//Custom Email Subject
var CES='{!CustomObject__c.Id} - Please eSign Vocus Sales Agreement';
//Custom Email Message
var CEM='I am sending you this request for your electronic signature, please review and electronically sign by following the link below.';
//Custom Envelop from Docusign
var DST = '00000000-33F0-4A8C-A8B2-00000000000';
//********* Page Callout (Do not modify) *********//
window.location.href ="/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!CustomObject__c.Id}&RC="+RC+"&RSL="+RSL+"&RSRO="+RSRO+"&RROS="+RROS+"&CCRM="+CCRM+"&CCTM="+CCTM+"&CRCL="+CRCL+"&CRL="+CRL+"&OCO="+OCO+"&DST="+DST+"&CCNM="+CCNM+"&LA="+LA+"&CEM="+CEM+"&CES="+CES+"&SRS="+SRS+"&STB="+STB+"&SSB="+SSB+"&SES="+SES+"&SEM="+SEM+"&SRS="+SRS+"&SCS="+SCS+"&RES="+RES;
//*******************************************//
Please do let me know what I am missing out.
Thanks in advance for helping out.
Most likely an issue with how you're setting CCRM and CCTM. Try changing to this instead (replace ALL_CAPS_TEXT with appropriate Role Names from the DocuSign Template you're using):
//Custom Contact Role Map
var CCRM='Signer 1~ROLE_NAME_OF_FIRST_RECIPIENT_IN_DOCUSIGN_TEMPLATE;Signer 2~ROLE_NAME_OF_SECOND_RECIPIENT_IN_DOCUSIGN_TEMPLATE';
//Custom Contact Type Map
var CCTM='Signer 1~Signer;Signer 2~Signer';
Notice that in setting the value of CCTM, the second value in each entry should simply be "Signer" (as shown above).
Also, since you're using a DocuSign Template (DST), you should verify that the Recipient Routing Order is set appropriately there as well.
Here's a (working) example for a custom button that sends to the first recipient first, and then when that recipient completes the envelope, sends to the second recipient:
Recipient Role Names & Routing Order as Defined by the DocuSign Template that the custom button uses:
Custom button code:
{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")}
//********* Option Declarations (Do not modify )*********//
var RC = '';var RSL='';var RSRO='';var RROS='';var CCRM='';var CCTM='';var CCNM='';var CRCL=''; var CRL='';var OCO='';var DST='';var LA='';var CEM='';var CES='';var STB='';var SSB='';var SES='';var SEM='';var SRS='';var SCS ='';var RES='';
//*************************************************//
//DocuSign Template
var DST='';
//Adding Notes & Attachments
var LA='1';
//Custom Recipient List
var CRL='Email~johnsemail#outlook.com;FirstName~user;LastName~1;Role~Signer 1;RoutingOrder~1,Email~janesemail#outlook.com;LastName~user2;Role~Signer 2;RoutingOrder~2,LoadDefaultContacts~1';
//Custom Contact Role Map
var CCRM='Signer 1~Customer;Signer 2~SalesRep';
//Custom Contact Type Map
var CCTM='Signer 1~Signer;Signer 2~Signer';
//Custom Email Subject
var CES='Please eSign Vocus Sales Agreement';
//Custom Email Message
var CEM='I am sending you this request for your electronic signature, please review and electronically sign by following the link below.';
//Custom Envelop from Docusign
var DST = '7C350ABB-74F9-463E-96E3-49153AA25607';
//********* Page Callout (Do not modify) *********//
window.location.href ="/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Opportunity.Id}&RC="+RC+"&RSL="+RSL+"&RSRO="+RSRO+"&RROS="+RROS+"&CCRM="+CCRM+"&CCTM="+CCTM+"&CRCL="+CRCL+"&CRL="+CRL+"&OCO="+OCO+"&DST="+DST+"&CCNM="+CCNM+"&LA="+LA+"&CEM="+CEM+"&CES="+CES+"&SRS="+SRS+"&STB="+STB+"&SSB="+SSB+"&SES="+SES+"&SEM="+SEM+"&SRS="+SRS+"&SCS="+SCS+"&RES="+RES;
//*******************************************//
This is the exact same button code that you provided in your question -- with only minor changes:
Changed email addresses in CRL (so I could test receiving the emails).
Changed CCRM to specify corrsponding Recipient Role Name from DocuSign Template for each signer.
Changed CCTM to use just "Signer" as the second portion for each item.
Changed DST to the ID of a Template in my DocuSign account (so I could test).
Updated window.location.href to use Opportunity.Id as SourceID (so I could test).
Once a user has authorized my app I need to parse the signed request so I can access their user id etc. Where in my code do I put the url to the page that processes it? I need a code example. I've looked through the documentation and it doesn't explain clearly how to do this for a canvas app. The variable redirectUrl has the url of the canvas app itself. Is that supposed to contain the url of the code that parses the signed request instead? I'm not sure.
<body>
<div id="fb-root"></div>
<script type="text/javascript">
$(document).ready(function(){
var appId = 278*****2040;
// If logging in as a Facebook canvas application use this URL.
var redirectUrl = "http://apps.facebook.com/MYAPP";
// If the user did not grant the app authorization go ahead and
// tell them that. Stop code execution.
if (0 <= window.location.href.indexOf ("error_reason"))
{
$('#authCancel').empty();
$(document.body).append ("<p>Authorization denied!</p>");
return;
}
// When the Facebook SDK script has finished loading init the
// SDK and then get the login status of the user. The status is
// reported in the handler.
window.fbAsyncInit = function(){
//debugger;
FB.init({
appId : 278****40,
status : true,
cookie : true,
oauth : true
});
// Sandbox Mode must be disabled in the application's settings
// otherwise the callback will never be invoked. Monitoring network
// traffic will show an error message in the response. Change the
// Sandbox Mode setting in: App Settings - Advanced - Authentication.
FB.getLoginStatus (onCheckLoginStatus);
};
// Loads the Facebook SDK script.
(function(d)
{
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
// Handles the response from getting the user's login status.
// If the user is logged in and the app is authorized go ahead
// and start running the application. If they are not logged in
// then redirect to the auth dialog.
function onCheckLoginStatus (response)
{
if (response.status != "connected")
{
top.location.href = "https://www.facebook.com/dialog/oauth?client_id=" + appId + "&redirect_uri=" + encodeURIComponent (redirectUrl) + "&scope=user_photos,friends_photos";
}
else
{
// Start the application (this is just demo code)!
$(document.body).append ("<p>Authorized!</p>");
FB.api('/me', function (response) {
$(document.body).append ("<pre>" + JSON.stringify (response, null, "\t") + "</pre>");
});
}
}
});
</script>
You can definitely use canvas page URL itself.
IN the same page you can put the following code. I have done that and working perfectly fine.
if(isset($_REQUEST["code"]))
{
$code = $_REQUEST["code"];
$my_url = "https://apps.facebook.com/CANVAS_APP_URL/";
$token_url = "https://graph.facebook.com/oauth/access_token?". "client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url)
. "&client_secret=" . $app_secret . "&code=" . $code;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $token_url );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output1 = curl_exec($ch);
curl_close($ch);
$tokenarray = explode("&", $output1);
$tokenarray1 = explode("=", $tokenarray[0]);
$access_token = $tokenarray1[1];
$urltoopen = 'https://graph.facebook.com/me?access_token=' . $access_token;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $urltoopen);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
}
Hope this helps !!
~ ABW