• conpas
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 12
    Replies

Hello, this is my doubt, how to get the current visualforce page id? I try with {!$Currentpage.Id} or $Page.Id but dont exists this variables.

 

Thanks.

  • November 03, 2011
  • Like
  • 0

Hello, i have a big problem. While I try to execute a simple line of code in the trigger class failed, but if i try to execute the same code in the VISUALFORCE(calling a class) or in the system debug log working fine. WHY???

 

My code is:

 NEWFOLDERINAMAZON newforlder = new NEWFOLDERINAMAZON('holaaaa33');

 

And mi class is:

public class NEWFOLDERINAMAZON {

    public NEWFOLDERINAMAZON(string folder) {

AWS_S3_ExampleController nf = new AWS_S3_ExampleController();
nf.constructor();
List<SelectOption> allBuckets = nf.getBucketNames();

nf.newfolder('testbank51',folder);

    }

}

 

 

And the error is:

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger chase caused an unexpected exception, contact your administrator: chase: execution of AfterInsert caused by: System.AssertException: Assertion Failed: Class.S3.AmazonS3.PutObjectInline_ACL: line 765, column 1

 

 

 

 

Thanks!!

  • November 02, 2011
  • Like
  • 0

Hello , I have a big problem. When i try to make a query in the rest api from apex salesforce, the VF return me a error: Read timed out .

This is my code:

 

httprequest req = new httprequest();
        req.setEndpoint('https://cs4.salesforce.com/services/data/v22.0/query/?q=SELECT Id, (SELECT Id, StepStatus, Comments, OriginalActorId, CreatedDate FROM Steps where StepStatus!=\'Started\' AND StepStatus != \'Reassigned\' Order by CreatedDate Desc) FROM ProcessInstance Where TargetObjectId = \''+TargetObjectId+'\' Order by CreatedDate Desc');
        req.setMethod('GET');
        req.setHeader('Authorization', 'OAuth ' + token);
        req.setTimeout(60000);
 

 

If I try to do a next request, work fine:

 

https://cs4.salesforce.com/services/data/v22.0/sobject/Case/XXXXX

 

But if I try to make a query, return me the timeout error, WHY?

 

Thanks.

  • October 18, 2011
  • Like
  • 0

Helle, i want to build the testmethod apex class for a apex class trigger, but i dont obtain any result.

 

trigger t on Account (after update) {
      for (Account a : Trigger.new) {
      List<Contact> contactdata = [Select Id, AccountId, Name From Contact where AccountId = :a.Id];
if(contactdata.size()>0) {
List<User> userdata = [Select Id, ContactId From User where ContactId = :contactdata.get(0).Id];
if(userdata.size()>0) {
userdata.get(0).accspot__c = a.Spot_lead_time__c;
userdata.get(0).accstory__c = a.Storyboard_lead_time__c;
update userdata.get(0);
}
}
}
}

 

 

Thanks!!!

  • October 04, 2011
  • Like
  • 0

Hello, i failed to use the amazon api for apex in the customer portal.

I my VF page i put:

<apex:page standardController="AWS_S3_Object__c" extensions="S3FormController">
</apex:page>

 

And my controller is:

 

public class S3FormController {
    public string jid = ApexPages.currentPage().getParameters().get('jid');
    public AWSKeys credentials {get;set;}
    private String AWSCredentialName = 'pruebaconpas'; //Modify this string variable to be the name of the AWS Credential record that contains the proper AWS keys and secret
    public string secret { get {return credentials.secret;} }
    public string key { get {return credentials.key;} }
   
    public AWS_S3_Object__c record; //  { get { return (AWS_S3_Object__c)con.getRecord(); }}
    public S3.AmazonS3 as3 { get; private set; }
    public String serverURL {get;set;}
   
    ApexPages.StandardController con;
    public string getjid() {
    return jid;
    }
    public S3FormController(ApexPages.StandardController stdController) {
        this.con = stdController;
        system.debug( con.getRecord() );
        try {
        this.record = [select id,bucket_name__c,content_type__c, file_name__c, access__c from AWS_S3_Object__c where id = :con.getRecord().id limit 1];
        } catch( Exception ee) {
            this.record = new   AWS_S3_Object__c();
        }
        //as3 = new S3.AmazonS3(credentials.key,credentials.secret);
    }
   
   
     /*
       This method is called when the news3object Visualforce page is loaded. It verifies that the AWS Keys can be found
       in the AWSKeys__c custom object by the specified name, as set in the string variable AWSCredentialsName.
      
       Any errors are added to the ApexPage and displayed in the Visualforce page.
    */
    public PageReference constructor(){
        try{
           
            credentials = new AWSKeys(AWSCredentialName);
            as3 = new S3.AmazonS3(credentials.key,credentials.secret);
       
        }catch(AWSKeys.AWSKeysException AWSEx){
             System.debug('Caught exception in AWS_S3_ExampleController: ' + AWSEx);
             ApexPages.Message errorMsg = new ApexPages.Message(ApexPages.Severity.FATAL, AWSEx.getMessage());
             ApexPages.addMessage(errorMsg);
             //throw new AWSKeys.AWSKeysException(AWSEx);
             //ApexPages.addMessage(AWSEx);   
        }  
   
       return null;
    }
   

    datetime expire = system.now().addDays(1);
    String formattedexpire = expire.formatGmt('yyyy-MM-dd')+'T'+
        expire.formatGmt('HH:mm:ss')+'.'+expire.formatGMT('SSS')+'Z';          
         
    string policy { get {return
        '{ "expiration": "'+formattedexpire+'","conditions": [ {"bucket": "'+
        record.Bucket_Name__c +'" } ,{ "acl": "'+
        record.Access__c +'" },'+
    //  '{"success_action_status": "201" },'+
        '{"content-type":"'+record.Content_Type__c+'"},'+
        '{"success_action_redirect": "https://'+serverurl+'/'+record.id+'"},' +
        '["starts-with", "$key", ""] ]}';   } }
   
    public String getPolicy() {
        return EncodingUtil.base64Encode(Blob.valueOf(policy));
    }
   
    public String getSignedPolicy() {   
        return make_sig(EncodingUtil.base64Encode(Blob.valueOf(policy)));       
    }
   
    // tester
    public String getHexPolicy() {
        String p = getPolicy();
        return EncodingUtil.convertToHex(Blob.valueOf(p));
    }
   
    //method that will sign
    private String make_sig(string canonicalBuffer) {       
        String macUrl ;
        String signingKey = EncodingUtil.base64Encode(Blob.valueOf(secret));
        Blob mac = Crypto.generateMac('HMacSHA1', blob.valueof(canonicalBuffer),blob.valueof(Secret));
        macUrl = EncodingUtil.base64Encode(mac);               
        return macUrl;
    }
   
    public String bucketToList {get;set;}
    public List<SelectOption> getBucketOptions(){
        try{
            Datetime now = Datetime.now();
            S3.ListAllMyBucketsResult allBuckets = as3.ListAllMyBuckets(
                key,now,as3.signature('ListAllMyBuckets',now));
           
            List<SelectOption> options = new List<SelectOption>();
           
            for(S3.ListAllMyBucketsEntry bucket:  allBuckets.Buckets.Bucket ){
                options.add(new SelectOption(bucket.Name,bucket.Name));
            }
            return options;
        }catch (System.NullPointerException e) {
           return null;
        }catch(Exception ex){
           //System.debug(ex);
           System.debug('caught exception in listallmybuckets');
           ApexPages.addMessages(ex);
           return null;
        }
    }
   
    public pageReference save1() {
        con.save();
        PageReference p = new PageReference('/apex/news3object2?id='+ con.getRecord().id );
        p.getParameters().put('urlParam',serverURL);
        p.setRedirect(true);
        return p;  
    }
   
    public pageReference page2onLoad(){
       PageReference tempPageRef = constructor();
       // Need to get the salesforce.com server from the URL
       System.debug('serverURL: ' +  ApexPages.currentPage().getParameters().get('urlParam'));
       serverURL = ApexPages.currentPage().getParameters().get('urlParam');
       //System.debug('serverURL: ' + serverURL);
       String urlDomain = serverURL.substring(serverURL.indexOf('://')+3,serverURL.indexOf('/services'));
       System.debug('URL Domain: ' + urlDomain);
       serverURL = urlDomain;
       return null;
    }

        
    public static testmethod void t1() {
        AWS_S3_Object__c a = new AWS_S3_Object__c();
       
        S3FormController s3 = new S3FormController(
            new ApexPages.StandardController( a ) );
       
        AWSKey__c testKey = new AWSKey__c(name='test keys',key__c='key',secret__c='secret');
        insert testKey;

        s3.AWSCredentialName = testKey.name;
        s3.constructor();
        system.debug( s3.secret + ' '+ s3.key );
        system.debug( s3.getpolicy() );
        system.debug( s3.getSignedPolicy() );
        system.debug( s3.getHexPolicy() );
       
        PageReference pageRef = Page.news3object;
        pageRef.getParameters().put('urlParam','https://na22.salseforce.com/services/soap/14.0/c/');
        Test.setCurrentPage(pageRef);
       
        s3.save1();
        s3.page2onLoad();
        system.debug( s3.getBucketOptions() );
    }
   
    public static testmethod void t2() {
        AWS_S3_Object__c a = new AWS_S3_Object__c();
        S3FormController s3 = new S3FormController(new ApexPages.StandardController( a ) );
        s3.AWSCredentialName = 'bad key name';
        s3.constructor();
    }
}

 

 

 

Why failed to execute in the customer portal? For the standard users works.

 

Thanks.

  • September 22, 2011
  • Like
  • 0

Hello, I spend a lot of time in search how to use the rest api, but only i find information to use the rest api with oAuth, but in dont want to use oauth, i want to type the username and password in the code and this is all, i want to make an app where the client dont see any rest api comunication, I mean execute the apex code in background.

 

I find a code in http://208.69.57.141/index.php/2011/05/using-the-salesforce-rest-api-with-javascript-and-jquery-in-visualforce-pages-using-apex/#comments

 

 

But show me a error [{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]

 

Thanks

  • September 08, 2011
  • Like
  • 0

Hello, I using the SOAP API and I need see the xml comunication from PHP to api server and from api server to PHP, how to configure the api script to see this information?

 

THanks!

  • September 07, 2011
  • Like
  • 0

Hello, i have a big problem when i try to use soap api whith apex. I copy and paste the xml code to send to the api from the official documentation, but show the error  SOAPAction HTTP header missing 

 

http://wiki.developerforce.com/index.php/Enterprise_Login

 

Why???? I dont understand. Thanks

  • September 07, 2011
  • Like
  • 0

I try to create a new workflow step, but the api show me a error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY

 

$records[0] = new stdclass();
$records[0]->StepStatus = 'Approved';
$records[0]->Comments = 'hello';
$records[0]->ProcessInstanceId = '04g50000000n0xxAAA';


$response = $mySforceConnection->create($records, 'ProcessInstanceStep');

print_r($response);


 

You can see, the propiety support the create funcion, but dont work!!

http://www.salesforce.com/us/developer/docs/api/index_Left.htm#CSHID=sforce_api_objects_approval.htm|StartTopic=Content%2Fsforce_api_objects_approval.htm|SkinName=webhelp

 

Thanks.

 

 

 

  • August 22, 2011
  • Like
  • 0

This is my question. I try to retrieve a custom field from a custom object, but I cant.

 

My controller code:

 

public class viewcase {
    String Name = ApexPages.currentPage().getParameters().get('Name');
    public List<prueba__c> getData() {     
            return Database.query('select Name, Language__c, Theme__c, FTP__c from prueba__c limit 10');
    }
   
           
}

 

 

Mi page:

 

<apex:page showHeader="false" controller="viewcase" cache="false">
        <apex:stylesheet value="{!URLFOR($Resource.SiteSamples, 'estilos.css')}" />
<apex:image id="johnryanheaderimage" value="http://www.conpas.net/jr/php5MJFUrAM.jpg" style="padding:15px;"/>
            <center> <a href="newcase">New case</a> | <a href="mycases">My cases</a> | <a href="myopenedcases">My opened cases</a> </center>
        <apex:pageBlock title="My cases" mode="edit">
        <apex:dataList value="{!Data}" var="d" id="theList">

        <apex:outputText value="-{!d.ID}"/>
        <apex:outputText value="-{!d.FTP__c}"/>
        <apex:outputText value="-{!d.Name}"/>
    </apex:dataList>
    </apex:pageBlock>

</apex:page>

I see empty the custom fields, why? I try to activate all security doors, but maybe this no is the way.

 

Thanks.

  • August 19, 2011
  • Like
  • 0

 Hello,

I have an problem. I try to use data table apex function in my page, but show me empty always. The controller return good data, but something happens in "apex:dataTable". This is my code:

<apex:page controller="exampleCon" cache="false">
  <apex:dataTable value="{!contacts}" var="c" id="theTable" rowClasses="odd,even" styleClass="tableClass">

        <apex:column><apex:facet name="header">Name</apex:facet>
            <apex:outputText value="-{!c.Name}"/>
        </apex:column>

        <apex:column>
            <apex:facet name="header">Phone</apex:facet>
            <apex:outputText value="-{!c.Phone}"/>

        </apex:column>

    </apex:dataTable>

</apex:page>


And my controller:

public class exampleCon {

    List<Contact> contacts;

    public List<Contact> getcontacts() {
        contacts = [select Name, Phone from Contact limit 10];     
        return contacts;
    }
}


Thanks.

  • August 18, 2011
  • Like
  • 0

Hello, i have a big problem. While I try to execute a simple line of code in the trigger class failed, but if i try to execute the same code in the VISUALFORCE(calling a class) or in the system debug log working fine. WHY???

 

My code is:

 NEWFOLDERINAMAZON newforlder = new NEWFOLDERINAMAZON('holaaaa33');

 

And mi class is:

public class NEWFOLDERINAMAZON {

    public NEWFOLDERINAMAZON(string folder) {

AWS_S3_ExampleController nf = new AWS_S3_ExampleController();
nf.constructor();
List<SelectOption> allBuckets = nf.getBucketNames();

nf.newfolder('testbank51',folder);

    }

}

 

 

And the error is:

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger chase caused an unexpected exception, contact your administrator: chase: execution of AfterInsert caused by: System.AssertException: Assertion Failed: Class.S3.AmazonS3.PutObjectInline_ACL: line 765, column 1

 

 

 

 

Thanks!!

  • November 02, 2011
  • Like
  • 0

Helle, i want to build the testmethod apex class for a apex class trigger, but i dont obtain any result.

 

trigger t on Account (after update) {
      for (Account a : Trigger.new) {
      List<Contact> contactdata = [Select Id, AccountId, Name From Contact where AccountId = :a.Id];
if(contactdata.size()>0) {
List<User> userdata = [Select Id, ContactId From User where ContactId = :contactdata.get(0).Id];
if(userdata.size()>0) {
userdata.get(0).accspot__c = a.Spot_lead_time__c;
userdata.get(0).accstory__c = a.Storyboard_lead_time__c;
update userdata.get(0);
}
}
}
}

 

 

Thanks!!!

  • October 04, 2011
  • Like
  • 0

I try to create a new workflow step, but the api show me a error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY

 

$records[0] = new stdclass();
$records[0]->StepStatus = 'Approved';
$records[0]->Comments = 'hello';
$records[0]->ProcessInstanceId = '04g50000000n0xxAAA';


$response = $mySforceConnection->create($records, 'ProcessInstanceStep');

print_r($response);


 

You can see, the propiety support the create funcion, but dont work!!

http://www.salesforce.com/us/developer/docs/api/index_Left.htm#CSHID=sforce_api_objects_approval.htm|StartTopic=Content%2Fsforce_api_objects_approval.htm|SkinName=webhelp

 

Thanks.

 

 

 

  • August 22, 2011
  • Like
  • 0

This is my question. I try to retrieve a custom field from a custom object, but I cant.

 

My controller code:

 

public class viewcase {
    String Name = ApexPages.currentPage().getParameters().get('Name');
    public List<prueba__c> getData() {     
            return Database.query('select Name, Language__c, Theme__c, FTP__c from prueba__c limit 10');
    }
   
           
}

 

 

Mi page:

 

<apex:page showHeader="false" controller="viewcase" cache="false">
        <apex:stylesheet value="{!URLFOR($Resource.SiteSamples, 'estilos.css')}" />
<apex:image id="johnryanheaderimage" value="http://www.conpas.net/jr/php5MJFUrAM.jpg" style="padding:15px;"/>
            <center> <a href="newcase">New case</a> | <a href="mycases">My cases</a> | <a href="myopenedcases">My opened cases</a> </center>
        <apex:pageBlock title="My cases" mode="edit">
        <apex:dataList value="{!Data}" var="d" id="theList">

        <apex:outputText value="-{!d.ID}"/>
        <apex:outputText value="-{!d.FTP__c}"/>
        <apex:outputText value="-{!d.Name}"/>
    </apex:dataList>
    </apex:pageBlock>

</apex:page>

I see empty the custom fields, why? I try to activate all security doors, but maybe this no is the way.

 

Thanks.

  • August 19, 2011
  • Like
  • 0

 Hello,

I have an problem. I try to use data table apex function in my page, but show me empty always. The controller return good data, but something happens in "apex:dataTable". This is my code:

<apex:page controller="exampleCon" cache="false">
  <apex:dataTable value="{!contacts}" var="c" id="theTable" rowClasses="odd,even" styleClass="tableClass">

        <apex:column><apex:facet name="header">Name</apex:facet>
            <apex:outputText value="-{!c.Name}"/>
        </apex:column>

        <apex:column>
            <apex:facet name="header">Phone</apex:facet>
            <apex:outputText value="-{!c.Phone}"/>

        </apex:column>

    </apex:dataTable>

</apex:page>


And my controller:

public class exampleCon {

    List<Contact> contacts;

    public List<Contact> getcontacts() {
        contacts = [select Name, Phone from Contact limit 10];     
        return contacts;
    }
}


Thanks.

  • August 18, 2011
  • Like
  • 0