• c_r_carvalho
  • NEWBIE
  • 35 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 6
    Questions
  • 7
    Replies
Hi Guys,

Well I developed the following code:
 
List< OauthToken > lstOauthToken = [Select id, user.name, accesstoken From OauthToken Where userid =: Userinfo.getUserId() AND 
        	(appname = 'Salesforce1 for Android' OR appname = 'Salesforce1 for iOS')];
        system.debug('CR=lstOauthToken=size= '+lstOauthToken.size());
        system.debug('CR=lstOauthToken=accesstoken= '+lstOauthToken[0].accesstoken);
        String urlRevoke = 'https://login.salesforce.com/services/oauth2/revoke?token=';
        urlRevoke += lstOauthToken[0].accesstoken;
        system.debug('CR=urlRevoke= '+urlRevoke);
        HttpRequest req = new HttpRequest();
        req.setEndpoint(urlRevoke);
        req.setHeader('Content-Type','application/x-www-form-urlencoded');
        req.setMethod('GET');
        
        Http http = new Http();
        HttpResponse res = http.send(req);
        system.debug('CR=response= '+res);

However when I get the access code to revoke it I got this debug, look:

Endpoint=https://login.salesforce.com/services/oauth2/revoke?token=(hidden)
I don't know why I cannot to see this code.
Because of that I got this error message: System.HttpResponse[Status=Bad Request, StatusCode=400]

Anybody can help me?
Hi Guys!

I develop a lightning component but the force:showToast function it's not working when I put the lightning component embed in a visualforce page. But works out of visualforce page.

Someone knows if this operation disrupts the function showToast?
How do I make this works embed in visualforce?

Thanks!
Hi, 

I have a class with a static variable and i'm trying to access this variable from a trigger and a receive this error.
But this error happens in production environment only.

Someone tell me why?

Example class:

public class CustomClass{
    public static boolean run = false;
    /*

     CODE HERE
    */
}


Example trigger:

trigger CustomObject on CustomObject__c(before insert, before update){
  if( CustomClass.run ) return;
  
  //CODE HERE
}


Thank you!
Hi,

I created a visualforce with apex:map and it works.
But when i generate PDF page the image is not rendered.

My code:

<apex:map width="400px" height="200px" mapType="hybrid" zoomlevel="15" 
             center="{!mapLatitudeLongitude}" rendered="{!Account.Latitude__c!=null}">
</apex:map>

It works if I don't set the RenderAs="PDF" on the page.

Helps!??

tks,
I'm trying to do a custom approve method:

List< ProcessInstanceWorkitem > listAprovacoes = [Select Id,ProcessInstanceId, OriginalActorId, CreatedDate, CreatedById,      ActorId  FROM ProcessInstanceWorkitem WHERE ProcessInstance.TargetObjectId =: guia.Id ORDER BY CreatedDate desc limit 1];
ProcessInstanceWorkitem lWorkItem;
lWorkItem = listAprovacoes[0];
Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();
req.setComments( parecerTecnico.Justificativa__c );
req.setAction('Approve');
req.setWorkitemId( lWorkItem.Id );
Approval.ProcessResult result =  Approval.process( req );

After invoke this method the record was approved BUT no one Approve Action was called.

Somebody knows why?

Tks for help.

When I create a queue on browser, it's possible to configure two sbjects or more in a queue, but i can't to do the same thing in apex class.
How can I accomplished this?

For instance:

QueueSobject qs = new QueueSobject(SobjectType='MyObject1__c;MyObject2__c', Name='My queue test');
Database.insert( qs );

This is what i want or something like that.

tks,
Hi Guys,

Well I developed the following code:
 
List< OauthToken > lstOauthToken = [Select id, user.name, accesstoken From OauthToken Where userid =: Userinfo.getUserId() AND 
        	(appname = 'Salesforce1 for Android' OR appname = 'Salesforce1 for iOS')];
        system.debug('CR=lstOauthToken=size= '+lstOauthToken.size());
        system.debug('CR=lstOauthToken=accesstoken= '+lstOauthToken[0].accesstoken);
        String urlRevoke = 'https://login.salesforce.com/services/oauth2/revoke?token=';
        urlRevoke += lstOauthToken[0].accesstoken;
        system.debug('CR=urlRevoke= '+urlRevoke);
        HttpRequest req = new HttpRequest();
        req.setEndpoint(urlRevoke);
        req.setHeader('Content-Type','application/x-www-form-urlencoded');
        req.setMethod('GET');
        
        Http http = new Http();
        HttpResponse res = http.send(req);
        system.debug('CR=response= '+res);

However when I get the access code to revoke it I got this debug, look:

Endpoint=https://login.salesforce.com/services/oauth2/revoke?token=(hidden)
I don't know why I cannot to see this code.
Because of that I got this error message: System.HttpResponse[Status=Bad Request, StatusCode=400]

Anybody can help me?
Hi I'm trying to follow the example here https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_one_demo_load.htm.

Atfter setting it up, I got this error when previewing it by clicking on the preview button:
Something has gone wrong. Unable to get property 'setParams' of undefined or null reference. Please try again.

I think it's the helper js "getContacts" where

var toastEvent = $A.get("e.force:showToast");
            if (state === 'SUCCESS'){
                toastEvent.setParams({
                    "title": "Success!",
                    "message": " Your contacts have been loaded successfully."
                });
            }

e.force:showToast appears to be a system function. Can someone confirm? Does this function only work on Salesforce1?

I'm following the documtation found at https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_add_cmp_salesforce1.htm , but even with the 'implements="force:appHostable"' set in my aura:component, the Lightning Component isn't available when I try to add a new Lightning Tab.

Any insight?

How to authenticate google service account for google adword api. By using this document. 
https://developers.google.com/accounts/docs/OAuth2ServiceAccount
My code Is as following :
public class GoogleAdWordApi{
     public Static String getAccessToken(){
        String accesstoken = '';
        
        String headerStr64 = EncodingUtil.base64Encode(Blob.valueOf('{"alg":"RS256","typ":"JWT"}'));
        headerStr64 = headerStr64.split('=')[0];

        String str = '{"iss":"965360208690-a6qbrksf61b5dl7punv126ntb5aspu93@developer.gserviceaccount.com",';
        str += '"scope":"' + 'https://www.googleapis.com/auth/prediction' + '",';
        str += '"aud":"' + 'https://accounts.google.com/o/oauth2/token' + '",';
        str += '"exp":' + system.now().addminutes(30).gettime()/1000 + ',';
        str += '"iat":'+system.now().gettime()/1000;
        str += '}';
        
        System.debug('@@@ str==>'+str);
        
        String claim_set64 = EncodingUtil.base64Encode(Blob.valueOf(str));
        claim_set64 = claim_set64.split('=')[0];
        System.debug('@@ claim_set64==>'+claim_set64);
        
        //make signature
        String sigInputstr =   headerStr64 + '.' + claim_set64 ;
        Blob signInputByteData = Blob.valueOf(sigInputstr);
        Blob signByteData = System.Crypto.signWithCertificate('RSA-SHA256',signInputByteData,'privatekey');
        String sigStr64 = EncodingUtil.base64Encode(signByteData);
        System.debug('@@@ sigStr64==>'+sigStr64);
        sigStr64 = sigStr64.split('=')[0];
        System.debug('@@@ sigStr64==>'+sigStr64);
        
        String jwtStr = headerStr64 + '.' + claim_set64 + '.' + sigStr64;
        
        System.debug('@@@ jwtStr==>'+jwtStr);
        
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://accounts.google.com/o/oauth2/token');
        req.setMethod('POST');
        req.setHeader('Host','accounts.google.com');
        req.setHeader('Content-Type','application/x-www-form-urlencoded');
        String body = 'grant_type='+ EncodingUtil.urlEncode('urn:ietf:params:oauth:grant-type:jwt-bearer','UTF-8');
        body += '&assertion=' + jwtStr;
        req.setBody(body);
        System.debug('@@ body==>'+body);
        Http http = new Http();
        HTTPResponse res = http.send(req);
        System.debug(res.getBody());    
        
        return accesstoken;
    }
}
--------------------------
Please tell me what is going worng with it.

Hi All,

Thanks for looking at this issue.

 

I am approving opportunities from a trigger as:

 

Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();
req.setComments('Approving request using Trigger');
req.setAction('Approve');
ProcessInstanceWorkitem workItem = [Select p.Id from ProcessInstanceWorkitem p where p.ProcessInstance.TargetObjectId =: opp.Id];
Id workItemId = workItem.Id;
req.setWorkitemId(workItemId);
Approval.ProcessResult result1 =  Approval.process(req);

 

I have some final approval actions set on opportunity approval process.

 

But these actions are not executed whe opportunities are approved from triger.

 

Any thoughts?

 

Thanks,

Bakul

Hi,

 

I've written a test that creates a new user using the system admin profile. I select the proflie with this query in my test 

 

Profile p = [SELECT Id,Name FROM Profile WHERE Name='System Administrator'];

 

The problem is that if the running user is not english the profile name is different. So if I change my language setting and run the same test I get List has no rows for assignment to SObject because the Name is now 'Administrador del sistema'. So my question is, how can I select the standard System Administrator profile in my test in a way that is language independent? I thought I might be able to use the license key but the key is the same for all standard profile licenses. 

 

Thanks for any help!

Hi All,

Thanks for looking at this issue.

 

I am approving opportunities from a trigger as:

 

Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();
req.setComments('Approving request using Trigger');
req.setAction('Approve');
ProcessInstanceWorkitem workItem = [Select p.Id from ProcessInstanceWorkitem p where p.ProcessInstance.TargetObjectId =: opp.Id];
Id workItemId = workItem.Id;
req.setWorkitemId(workItemId);
Approval.ProcessResult result1 =  Approval.process(req);

 

I have some final approval actions set on opportunity approval process.

 

But these actions are not executed whe opportunities are approved from triger.

 

Any thoughts?

 

Thanks,

Bakul