• Tanya Shah
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 14
    Replies
Whenever Opportunity Stage is Updated to “Closed Won” , need to update them on the OpportunityIineItem using trigger . Have created a custom field to update the systemdate.

It is giving me error "Error: Compile Error: Initial term of field expression must be a concrete SObject: LIST<OpportunityLineItem> at line 17 column 9 " . Where am i makeing mistake ?

 
​trigger OpportunityWon on Opportunity (after update) {

  Set<Id> relevantIds = new Set<Id>();
    // select relevant opportunities
    for(Opportunity o : trigger.new)
    {
        if(o.StageName == 'Closed Won' || trigger.oldMap.get(o.Id).StageName == 'Closed Won')
        {
            relevantIds.add(o.Id);
        }
    }

    // Line Items
   OpportunityLineItem[] olis = [SELECT ID, WonWhen__c, OpportunityId FROM OpportunityLineItem WHERE OpportunityId IN :relevantIds];
   for(OpportunityLineItem oli :olis )
   {
        olis.WonWhen__c = system.today();
   }

  if (olis.size()>0)
    update olis.values();

}

 
I want to write a trigger to Update product dates when opp close date changes .
There are number of products added to particular opportunity and each one has different ServiceDate .Following is what i tried ,
 
trigger productUpdate on Opportunity (after update) {
		
	OpportunityLineItem[] olis = [SELECT OpportunityId, ServiceDate, Opportunity.CloseDate FROM OpportunityLineItem WHERE OpportunityId IN :Trigger.New];
    for(OpportunityLineItem oli :olis)
     {

      oli.ServiceDate = Trigger.newMap.get(oli.OpportunityId).CloseDate.addDays(oli.ServiceDate.daysBetween(oli.Opportunity.CloseDate));
   
     }
	update olis;

 }
This is working but not giving me improper dates . Something random . I want to refer to below link to get it to similar way

http://thysmichels.com/2012/04/10/salesforce-update-product-schedule-from-opportunity-product-using-apex-trigger/

Thank you !
I've written a trigger to update product dates.There are number of products added to particular opportunity and each one has different ServiceDate . So I want to add the difference (service date - Opportunity.closeDate) to each of them so that every product service date is pushed to a new date with difference equal to the number of days between service date and close date. 

Please help !
trigger productUpdate on Opportunity (after update) {
	
	// declare list to hold opportuity line item
	OpportunityLineItem[] olis = [SELECT Id, Name, ServiceDate, Opportunity.CloseDate FROM OpportunityLineItem WHERE OpportunityId IN :Trigger.New];
	for(OpportunityLineItem oli : olis ){
		// perform logic to bumb date somehow...
		//oli.ServiceDate = oli.Opportunity__r.CloseDate + (10);
		Integer dat=oli.ServiceDate.day();
		System.debug('dat prod '+ oli + dat);
		Integer dot=oli.Opportunity.CloseDate.day();
		System.debug('opp cd '+ dot);
		Integer diff=dat-dot;
	//	integer diff = dat.daysBetween(dot);
	    System.debug('diff'+ diff);
        oli.ServiceDate = Trigger.newMap.get(oli.OpportunityId).CloseDate.addDays(diff); 
      
   }
	update olis;

}

 
I want to write a trigger to Update product dates when opp close date changes .
 
For eg.
Opportunity Close Date:  11/29/2014    (Nov 29th 2014)
Prod 1 Start Date :   12/9/2014   (10 days from Opportunity Close date)
Prod 2 Start Date:    12/23/2014  (22 days from opportunity close date)

Please help. Thanks in advance .
I'm trying to show image through API . But the image doesnt show up on page . With debugging it is showing image as null . Am i missing something or doing wrong ? Please help.
Thank you !

Apex
 
public class RestImage {

public Blob image {get;set;}
public string code {get;set;}
public string values {get;set;}
public void myConnection(){

    http p =new http();
    httprequest req= new httprequest();
    req.setEndpoint('https://s3.amazonaws.com/soap');
    req.setMethod('GET');
    req.setTimeout(11000);
    
    httpresponse res= p.send(req);
    code=res.getStatus();
    values=res.getBody();
    image=res.getBodyAsBlob();
   // image=EncodingUtil.base64encode(res.getBodyAsBlob());

    System.debug(res.getBody());
    System.debug(image);
  
   }
 }
Visualforce
 
<apex:page controller="RestImage" action="{!myConnection}">
  {!code}{!values}
  <apex:form > {!image}</apex:form>
  
  <apex:image value="data:image/gif;base64,{!image}" />

</apex:page>


 
  I have an image where i need to zoom in and zoom out the image . How do i go about it . Not getting proper solutions until now .
            
<apex:image id="theImage" value="https://s3.amazonaws.com/{!bucketToList}/{!obj.key}?AWSAccessKeyId=AKIAJGN4J4RSRNW26IEA&amp" width="100" height="100"> </apex:image>
  Please help .
How can i show images in this format by selecting this from drop down list ..Please help ! its really urgent . Its basically like how we see images in google , thumbnail . It would really helpful if its with sample code .

User-added image
I got this error while getting the list of buckets in Amazon S3 . I know there is already a toolkit available but just wanted to make this simple .  Getting an error Error: Compile Error: Invalid type: S3.AmazonS3 at line 12 column 12 . 

I'm really stucked here . Please help.

 Apex class
public class testAWS_S3_Controller {

    public String getAllBuckets() {
        return null;
    }
    
    public testAWS_S3_Controller() {}

    private String AWSCredentialName = 'Demo_S3_account'; //Modify this string variable to be the name of the AWS Credential record that contains the proper AWS keys and secret
    public String OwnerId {get;set;}
    public String S3Key {get;set;}
    public S3.AmazonS3 as3 {get; private set;} //This object represents an instance of the Amazon S3 toolkit and makes all the Web Service calls to AWS. 
    public S3.ListBucketResult listbucket {get;set;}
    public S3.ListBucketResult ListAllMyBuckets {get;set;}
    
    
    public class AmazonS3 {
        public AmazonS3(String key, String secret){
            this.key = key;
            this.secret= secret;    
        }
        
        public AmazonS3(){
            
        }
   //Method to return a string array for all the buckets in your AWS S3 account
    public String[] allBuckets {
        get {
            try {

                Datetime now = Datetime.now();

                //This performs the Web Service call to Amazon S3 and retrieves all the Buckets in your AWS Account. 
                S3.ListAllMyBucketsResult allBuckets = as3.ListAllMyBuckets(as3.key, now, as3.signature('ListAllMyBuckets', now));

                System.debug(allBuckets);

                //Store the Canonical User Id for your account
                OwnerId = allBuckets.Owner.Id;

                S3.ListAllMyBucketsList bucketList = allBuckets.Buckets;
                S3.ListAllMyBucketsEntry[] buckets = bucketList.Bucket;
                allBucketList = buckets;

                String[] bucketNames = new String[] {};


                //Loop through each bucket entry to get the bucket name and store in string array. 
                for (S3.ListAllMyBucketsEntry bucket: buckets) {
                    System.debug('Found bucket with name: ' + bucket.Name);

                    bucketNames.add(bucket.name);

                }

                return bucketNames;

            } catch (System.NullPointerException e) {
                return null;
            } catch (Exception ex) {
                //System.debug(ex);
                System.debug('caught exception in listallmybuckets');
                ApexPages.addMessages(ex);
                return null;
            }

        } //end getter
        set;
      }
   } 
   
 }

VF page
<apex:page controller="testAWS_S3_Controller">
<apex:outputPanel id="fullRefreshPageId">
<apex:form >

<br/>
<apex:pageBlock title="Force.com for Amazon Web Services">
<apex:pageMessages />

<!--  THIS PAGE BLOCK SECTION ILLUSTRATES HOW TO LIST ALL BUCKETS IN YOUR S3 ACCOUNT -->
<apex:pageBlockSection columns="1" title="List all Buckets in my S3 Account">

<apex:outputText value="Here is the list of buckets available in your S3 account." />
<apex:outputText value="This list is generated by the ListAllMyBuckets web service" />

<apex:dataList value="{!allBuckets}" var="bucket" id="theList">
        <apex:outputText value="{!bucket}"/>
</apex:dataList>
 </apex:pageBlockSection> 

   </apex:pageblock>   
  </apex:form>
    </apex:outputPanel>
  
</apex:page>

Thank you !
Hi experts,

I'm trying to integrate amazon S3 with Sales force, i did it with the toolkit. When it says to
upload image,it shows the image to a bigger size which I do not want.How do i resize it ?.Pressing my head onto this from many days . Can anybody please help me to fix this ?

Thank you !
Whenever Opportunity Stage is Updated to “Closed Won” , need to update them on the OpportunityIineItem using trigger . Have created a custom field to update the systemdate.

It is giving me error "Error: Compile Error: Initial term of field expression must be a concrete SObject: LIST<OpportunityLineItem> at line 17 column 9 " . Where am i makeing mistake ?

 
​trigger OpportunityWon on Opportunity (after update) {

  Set<Id> relevantIds = new Set<Id>();
    // select relevant opportunities
    for(Opportunity o : trigger.new)
    {
        if(o.StageName == 'Closed Won' || trigger.oldMap.get(o.Id).StageName == 'Closed Won')
        {
            relevantIds.add(o.Id);
        }
    }

    // Line Items
   OpportunityLineItem[] olis = [SELECT ID, WonWhen__c, OpportunityId FROM OpportunityLineItem WHERE OpportunityId IN :relevantIds];
   for(OpportunityLineItem oli :olis )
   {
        olis.WonWhen__c = system.today();
   }

  if (olis.size()>0)
    update olis.values();

}

 
I want to write a trigger to Update product dates when opp close date changes .
There are number of products added to particular opportunity and each one has different ServiceDate .Following is what i tried ,
 
trigger productUpdate on Opportunity (after update) {
		
	OpportunityLineItem[] olis = [SELECT OpportunityId, ServiceDate, Opportunity.CloseDate FROM OpportunityLineItem WHERE OpportunityId IN :Trigger.New];
    for(OpportunityLineItem oli :olis)
     {

      oli.ServiceDate = Trigger.newMap.get(oli.OpportunityId).CloseDate.addDays(oli.ServiceDate.daysBetween(oli.Opportunity.CloseDate));
   
     }
	update olis;

 }
This is working but not giving me improper dates . Something random . I want to refer to below link to get it to similar way

http://thysmichels.com/2012/04/10/salesforce-update-product-schedule-from-opportunity-product-using-apex-trigger/

Thank you !
I've written a trigger to update product dates.There are number of products added to particular opportunity and each one has different ServiceDate . So I want to add the difference (service date - Opportunity.closeDate) to each of them so that every product service date is pushed to a new date with difference equal to the number of days between service date and close date. 

Please help !
trigger productUpdate on Opportunity (after update) {
	
	// declare list to hold opportuity line item
	OpportunityLineItem[] olis = [SELECT Id, Name, ServiceDate, Opportunity.CloseDate FROM OpportunityLineItem WHERE OpportunityId IN :Trigger.New];
	for(OpportunityLineItem oli : olis ){
		// perform logic to bumb date somehow...
		//oli.ServiceDate = oli.Opportunity__r.CloseDate + (10);
		Integer dat=oli.ServiceDate.day();
		System.debug('dat prod '+ oli + dat);
		Integer dot=oli.Opportunity.CloseDate.day();
		System.debug('opp cd '+ dot);
		Integer diff=dat-dot;
	//	integer diff = dat.daysBetween(dot);
	    System.debug('diff'+ diff);
        oli.ServiceDate = Trigger.newMap.get(oli.OpportunityId).CloseDate.addDays(diff); 
      
   }
	update olis;

}

 
I want to write a trigger to Update product dates when opp close date changes .
 
For eg.
Opportunity Close Date:  11/29/2014    (Nov 29th 2014)
Prod 1 Start Date :   12/9/2014   (10 days from Opportunity Close date)
Prod 2 Start Date:    12/23/2014  (22 days from opportunity close date)

Please help. Thanks in advance .
I'm trying to show image through API . But the image doesnt show up on page . With debugging it is showing image as null . Am i missing something or doing wrong ? Please help.
Thank you !

Apex
 
public class RestImage {

public Blob image {get;set;}
public string code {get;set;}
public string values {get;set;}
public void myConnection(){

    http p =new http();
    httprequest req= new httprequest();
    req.setEndpoint('https://s3.amazonaws.com/soap');
    req.setMethod('GET');
    req.setTimeout(11000);
    
    httpresponse res= p.send(req);
    code=res.getStatus();
    values=res.getBody();
    image=res.getBodyAsBlob();
   // image=EncodingUtil.base64encode(res.getBodyAsBlob());

    System.debug(res.getBody());
    System.debug(image);
  
   }
 }
Visualforce
 
<apex:page controller="RestImage" action="{!myConnection}">
  {!code}{!values}
  <apex:form > {!image}</apex:form>
  
  <apex:image value="data:image/gif;base64,{!image}" />

</apex:page>


 
  I have an image where i need to zoom in and zoom out the image . How do i go about it . Not getting proper solutions until now .
            
<apex:image id="theImage" value="https://s3.amazonaws.com/{!bucketToList}/{!obj.key}?AWSAccessKeyId=AKIAJGN4J4RSRNW26IEA&amp" width="100" height="100"> </apex:image>
  Please help .
I got this error while getting the list of buckets in Amazon S3 . I know there is already a toolkit available but just wanted to make this simple .  Getting an error Error: Compile Error: Invalid type: S3.AmazonS3 at line 12 column 12 . 

I'm really stucked here . Please help.

 Apex class
public class testAWS_S3_Controller {

    public String getAllBuckets() {
        return null;
    }
    
    public testAWS_S3_Controller() {}

    private String AWSCredentialName = 'Demo_S3_account'; //Modify this string variable to be the name of the AWS Credential record that contains the proper AWS keys and secret
    public String OwnerId {get;set;}
    public String S3Key {get;set;}
    public S3.AmazonS3 as3 {get; private set;} //This object represents an instance of the Amazon S3 toolkit and makes all the Web Service calls to AWS. 
    public S3.ListBucketResult listbucket {get;set;}
    public S3.ListBucketResult ListAllMyBuckets {get;set;}
    
    
    public class AmazonS3 {
        public AmazonS3(String key, String secret){
            this.key = key;
            this.secret= secret;    
        }
        
        public AmazonS3(){
            
        }
   //Method to return a string array for all the buckets in your AWS S3 account
    public String[] allBuckets {
        get {
            try {

                Datetime now = Datetime.now();

                //This performs the Web Service call to Amazon S3 and retrieves all the Buckets in your AWS Account. 
                S3.ListAllMyBucketsResult allBuckets = as3.ListAllMyBuckets(as3.key, now, as3.signature('ListAllMyBuckets', now));

                System.debug(allBuckets);

                //Store the Canonical User Id for your account
                OwnerId = allBuckets.Owner.Id;

                S3.ListAllMyBucketsList bucketList = allBuckets.Buckets;
                S3.ListAllMyBucketsEntry[] buckets = bucketList.Bucket;
                allBucketList = buckets;

                String[] bucketNames = new String[] {};


                //Loop through each bucket entry to get the bucket name and store in string array. 
                for (S3.ListAllMyBucketsEntry bucket: buckets) {
                    System.debug('Found bucket with name: ' + bucket.Name);

                    bucketNames.add(bucket.name);

                }

                return bucketNames;

            } catch (System.NullPointerException e) {
                return null;
            } catch (Exception ex) {
                //System.debug(ex);
                System.debug('caught exception in listallmybuckets');
                ApexPages.addMessages(ex);
                return null;
            }

        } //end getter
        set;
      }
   } 
   
 }

VF page
<apex:page controller="testAWS_S3_Controller">
<apex:outputPanel id="fullRefreshPageId">
<apex:form >

<br/>
<apex:pageBlock title="Force.com for Amazon Web Services">
<apex:pageMessages />

<!--  THIS PAGE BLOCK SECTION ILLUSTRATES HOW TO LIST ALL BUCKETS IN YOUR S3 ACCOUNT -->
<apex:pageBlockSection columns="1" title="List all Buckets in my S3 Account">

<apex:outputText value="Here is the list of buckets available in your S3 account." />
<apex:outputText value="This list is generated by the ListAllMyBuckets web service" />

<apex:dataList value="{!allBuckets}" var="bucket" id="theList">
        <apex:outputText value="{!bucket}"/>
</apex:dataList>
 </apex:pageBlockSection> 

   </apex:pageblock>   
  </apex:form>
    </apex:outputPanel>
  
</apex:page>

Thank you !
Hi experts,

I'm trying to integrate amazon S3 with Sales force, i did it with the toolkit. When it says to
upload image,it shows the image to a bigger size which I do not want.How do i resize it ?.Pressing my head onto this from many days . Can anybody please help me to fix this ?

Thank you !