• SYM12
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 20
    Questions
  • 21
    Replies

Hi All,

 

I am trying to upload file through Rest API. i am able to upload and extract text files properly but if i upload any other file format (pdf,doc ,ppt or any image) , the file uploads fine but if i try to open that file it won't open( error message : file is broken , or the pdf is blank). It seems the file body i am sending is not properly encoded for other file formats.

Below is my code which i am using to upload files

*****************************************************
String ObjectName = input.filename;
System.debug('ObjectName' + ObjectName);
Blob BodyContent=input.fileBody;
String DocBody = BodyContent.toString();
// String DocBody = EncodingUtil.base64Encode(BodyContent);
// String DocBody = EncodingUtil.urlEncode(bodyContent.toString(), 'UTF-8');
// String DocBody1 =
System.debug('DocBody' + DocBody);
Integer bodyLength =DocBody.length();
System.debug('bodyLength ------------->' + bodyLength );

String url6=input.StorageURL;
Http h6 = new Http();

HttpRequest req6 = new HttpRequest();
req6.setTimeout(60000);
req6.setEndpoint(url6 + '/' + input.containerName + '/'+input.objectPath + '/' + ObjectName );//
System.debug(url6);
req6.setMethod('PUT');

req6.setHeader('X-Auth-Token',input.AuthToken);
req6.setHeader('Content-Type','application/octet-stream');
req6.setHeader('Content-Length',string.valueof(bodyLength));
req6.setHeader('X-Object-Meta-PIN','1234');
// System.debug('Request object is----------->' + req6);
req6.setBody(DocBody);
HttpResponse res6;
res6 = h6.send(req6);
*************************************************
if i upload a file directly to storage size is 15Kb but if i upload through API file size is showing 24 KB.

Please let me know do i need to encode the file body or am i missing any thing.

I have tried with encloding also but still no luck


Quick response would be appreciated!!

  • September 14, 2010
  • Like
  • 0

Hi All,

 

i have saved a file to some third party sever. I am making an APi call retriving the file and below is the response

 

HTTP/1.1 200 Ok
Date: Wed, 11 Jul 2007 19:37:41 GMT
Server: Apache
Last-Modified: Fri, 12 Jun 2007 13:40:18 GMT
ETag: b0dffe8254d152d8fd28f3c5e0404a10
Content-type: text/html
Content-Length: 512000
[ ... ]  (file content)

 

Now i need to create a link (view ) in vf page, so when a  user click this link he should be able to download the file(same view functionality in document or we can say save as functionality).

 

Please let me know, Do i need to bulid the file again or Is there quick java script where i can pass all these values and it will take care rest.

 

Thanks in Advance!!

  • September 08, 2010
  • Like
  • 0

Hi All,

 

i have saved a file to some third party sever. I am making an APi call retriving the file and below is the response

 

HTTP/1.1 200 Ok
Date: Wed, 11 Jul 2007 19:37:41 GMT
Server: Apache
Last-Modified: Fri, 12 Jun 2007 13:40:18 GMT
ETag: b0dffe8254d152d8fd28f3c5e0404a10
Content-type: text/html
Content-Length: 512000
[ ... ]  (file content)

 

Now i need to create a link (view ) in vf page, so when a  user click this link he should be able to download the file(same view functionality in document or we can say save as functionality).

 

Please let me know, Do i need to bulid the file again or Is there quick java script where i can pass all these values and it will take care rest.

 

Thanks in Advance!!

  • September 08, 2010
  • Like
  • 0

HI All,

 

I have stored contact field API name in other object as text.Now i am retriving that field name and need to convert as field token.

 

For eg:

list<CampSetup__c> allCampmember= [select id,ContactDate_ApiName__c,Name from CampSetup__c];
                 map<String,String> mapallcamp = new map<String,String>();


//map defines campaign name as key and contact date field Api name as value        

        if(!allCampmember.isEmpty())
             {
                  for(CampSetup__c cc :allCampmember)
                  {
                      mapallcamp.put(cc.Name,cc.ContactDate_ApiName__c);
                  }
            }

 

now i have all the field name values in my map

Campaign  camp = [select id,name from CampaignMember where id ='abdcksf'];

CampaignMember con = [select id,name,Contact.abcd__c from CampaignMember where id ='abdcksf'];

when i try try to access

Date dd =con.Contact.(mapallcamp.get(camp.name)) //which gives an error as the map value is a string not field token

 

Please let me konw how to get the fieldtoken.

 

 

 

  • July 14, 2010
  • Like
  • 0

Hi All,

 

i want to display dependent and controlling piclklist in Vf page.

i have tried using slect list and selct option but it showing all the value and i have read that Input fields are currently not supported dependent picklists.

i also dont want to hard code the values in the controller as it might change in future.

Is there any way i can make this as genric using describe or any workaround?

 

Thanks in advance

 

  • May 20, 2010
  • Like
  • 0

Hi All,

 

i got stuck writing an action handler.

 

I have some custom components and a visual for page , below is my code

 

<apex:page contentType="text/xml" showHeader="false" controller="DialMerchant">
    <Response>
    <Say>Hello, The number you have reached is in service and dialing merchant</Say>
        <Dial record="true" action="http://abcd-developer-edition.na7.force.com/Status">{!$CurrentPage.parameters.Called}</Dial>
    </Response>
</apex:page>

 

when this page is called it palays the message in <Say> and Dial the number mentioned in {!$CurrentPage.parameters.Called}.

Now after the call completes according to the telephonic developer they send the Status of call on the Action element specified in Dial Component which could be a Absolute or relative URL.

 

But it seems my vf page Status is never called.

 

how can i make sure if i am getting any POST request on the URL ( how to print debug or POST request as i have tried to put some debug in controller and never called).

 

Any comments will much appricieated.

 

Thanks in Advance

  • April 29, 2010
  • Like
  • 0

Hi All,

 

i got stuck writing an action handler.

 

I have some custom components and a visual for page , below is my code

 

<apex:page contentType="text/xml" showHeader="false" controller="DialMerchant">
    <Response>
    <Say>Hello, The number you have reached is in service and dialing merchant</Say>
        <Dial record="true" action="http://abcd-developer-edition.na7.force.com/Status">{!$CurrentPage.parameters.Called}</Dial>
    </Response>
</apex:page>

 

when this page is called it palays the message in <Say> and Dial the number mentioned in {!$CurrentPage.parameters.Called}.

Now after the call completes according to the telephonic developer they send the Status of call on the Action element specified in Dial Component which could be a Absolute or relative URL.

 

But it seems my vf page Status is never called.

 

how can i make sure if i am getting any POST request on the URL ( how to print debug or POST request as i have tried to put some debug in controller and never called).

 

Any comments will much appricieated.

 

Thanks in Advance

  • April 29, 2010
  • Like
  • 0

Hi All,

 

i want to create workflow programatically through trigger or apex class,is it possible?

 

Thanks in advance

  • April 21, 2010
  • Like
  • 0

How to create a HyperLink Formula on thr phone which will call my genric visual force page

 

Thanks in advance

  • April 16, 2010
  • Like
  • 0

Hi All,

 

I am getting hard time to create a link on a phone number. Actually i want to implement click to call functionality with some telephony company.

 

Now i want to right a generic visual force page which can be embedded in all the objects as a page layout or some kind of JavaScript which can create a link on all the phone numbers and which in turn call my visualforce page on clicking that number. I wanted to implement on all the phone numbers present in the org (For e.g. how skype is doing right noe).One more thing I don’t have any CTI.

 

Is there any way to achieve this? Please let me know if any one implemented this kind of functionality before.

 

Thanks in advance.

 

  • April 16, 2010
  • Like
  • 0

Hi All,

 

I am getting hard time to create a link on a phone number. Actually i want to implement click to call functionality with some telephony company.

 

Now i want to right a generic visual force page which can be embedded in all the objects as a page layout or some kind of JavaScript which can create a link on all the phone numbers and which in turn call my visualforce page on clicking that number. I wanted to implement on all the phone numbers present in the org (For e.g. how skype is doing right noe).One more thing I don’t have any CTI.

 

Is there any way to achieve this? Please let me know if any one implemented this kind of functionality before.

 

Thanks in advance.

 

  • April 16, 2010
  • Like
  • 0

Hi All,

 

i have written a trigger on campaign and which calls a future method when the campign is close. but i am getting the below error

 

Failed to invoke future method 'public static void updateLead(LIST:String)'

caused by: System.Exception: Too many callouts: 11

Class.TwilioRestClient.

request: line 70, column 32
Class.CommonUpdateUrl.UpdateOutOfServiceUrl: line 62, column 14
Class.CampClosed.updateLead: line 91, column 8
External entry point
below is the my class
public with sharing class CampClosed {

@future(callout=true)
public static void updateLead(List<String> CampaignList){

List<Lead> LeadToUnassign = new List<Lead>();
List<String> VN = new List<String>();
list<String> ListIds = new list<String>();
list<String> UpdateURL = new list<String>();
list<Lead_Virtual__c> vnn = new list<Lead_Virtual__c>();
if(CampaignList.size()>0)

    {   
        list<lead> Checklist = new list<Lead>();
        Checklist = [Select Id from Lead where FCCampaign__c In :CampaignList and Status ='Trial'limit 10];
        if(Checklist.size()>0){
          list<Twilio_URL__c> t1 = [select Id,Name,URL_Value__c from Twilio_URL__c  where Name = 'Out Of Service' limit 1];
        System.debug('Before Lead');
for(list<Lead> l1: [Select Id,Status,Phone,Virtual_Number__c,FCCampaign__c,Actual_End_Date__c,IsProvisioned__c,
                    (Select Id, Status__c From Lead_Virtuals__r) from Lead where FCCampaign__c In :CampaignList and Status ='Trial']) {
       for(Lead l2 :l1){
       VN.add(l2.Virtual_Number__c);
       l2.Status = 'Cancel';
       l2.Provisioning_Status__c ='Pending';
      l2.Virtual_Number__c= '';
      l2.Actual_End_Date__c= System.today();
      l2.IsProvisioned__c = false;                          
         LeadToUnassign.add(l2);
        ListIds.add(l2.Id);
       }
    //   for(Lead_Virtual__c temp :l1.Lead_Virtuals__r){
      //         temp.Status__c = 'Inactive';
        //     vnn.add(temp);
      // }
         if (LeadToUnassign.size() == 200) {
        //  for(Virtual_Number__c v1 :)
            try {
                list<Lead_Virtual__c> vr1 = [Select Id,Status__c from Lead_Virtual__c where Lead__c IN :ListIds
                                                                        and Status__c = 'Active'];
                List<Virtual_Number__c> V1 = new List<Virtual_Number__c>();
                V1 =[Select Id,Virtual_Number__c,SID__c,Twilio_URL__c from Virtual_Number__c where Virtual_Number__c IN :VN];
                for(Virtual_Number__c v2 :V1){
                    v2.Virtual_Number_Staus__c = 'Hold';
                    v2.Twilio_URL__c =t1[0].Id;
                    UpdateURL.add(v2.SID__c);
                }
                
                for(Lead_Virtual__c vr2 :vr1){
                    vr2.Status__c = 'Inactive';
                }
                System.debug('Before Update');
                if(UpdateURL.size()>=600){
                    CommonUpdateUrl.UpdateOutOfServiceUrl(UpdateURL);
                    UpdateURL.clear();
                }
                update LeadToUnassign;
                update V1;
                update vr1;
                System.debug('After Update');
                LeadToUnassign.clear();
                VN.clear();
                ListIds.clear();
            //  PassUpadateURLParametes.PassParameter(UpdateURL);
            

            } catch(Exception ex) {
                System.debug(' Exception Occured' + ex);     
            //  sentEmail(i);  
                LeadToUnassign.clear();
                VN.clear();
                ListIds.clear();    
            }                                           
       }  
                                 }                                              
    if (! LeadToUnassign.isEmpty()) {
        try {
            System.debug('2nd  if statement');
            list<Lead_Virtual__c> vr1 = [Select Id,Status__c from Lead_Virtual__c where Lead__c IN :ListIds
                                                                    and Status__c = 'Active'];
            List<Virtual_Number__c> V1 = new List<Virtual_Number__c>();
                V1 =[Select Id,Virtual_Number__c,SID__c,Twilio_URL__c from Virtual_Number__c where Virtual_Number__c IN :VN];
                for(Virtual_Number__c v2 :V1){
                    v2.Virtual_Number_Staus__c = 'Hold';
                    v2.Twilio_URL__c =t1[0].Id;
                    UpdateURL.add(v2.SID__c);
                }
                for(Lead_Virtual__c vr2 :vr1){
                    vr2.Status__c = 'Inactive';
                }
            if(!UpdateURL.isEmpty()){
                CommonUpdateUrl.UpdateOutOfServiceUrl(UpdateURL);
            }
                            update LeadToUnassign;
                update V1;
                update vr1;
            //  update VN;
            LeadToUnassign.clear();
                VN.clear();
        } catch(Exception ex) {
            System.debug(' Exception Occured' + ex);
        //  sentEmail(i);
        
        }
    }      
                                       }       
      else{
        System.debug('No Lead is Active');
           }                                                                            
                                       }                                        
    }
}
Please suggest how i can get over from this problem.
Thanks,

  • April 06, 2010
  • Like
  • 0

I am inserting records in a custom object name as RAW patient order through data loader and i have written a trigger which picks some values from this object and insert into patient and patient order objects.

 

We have to do one more additional check here for the patients. Customer mentioned that they will get the orders from the same patient over and over. In that scenario we should not be creating duplicate patients. We have to check for the following patient and see if it exists. If so, skip the creation process and just create patient orders alone by associating with the existing patients.

Unique Identifier for Patient: first name, last name and birth date

 

Now I am facing the problem that how would i check this condition from the database. if i go for soql query one by one for every inserting record than surly i will face soql execution limits.

 

Please suggest, if any one have any idea to achieve this functionality

 

Thanks in advance!!

  • March 14, 2010
  • Like
  • 0

I am inserting records in a custom object name as RAW patient order through data loader and i have written a trigger which picks some values from this object and insert into patient and patient order objects.

 

We have to do one more additional check here for the patients. Customer mentioned that they will get the orders from the same patient over and over. In that scenario we should not be creating duplicate patients. We have to check for the following patient and see if it exists. If so, skip the creation process and just create patient orders alone by associating with the existing patients.

Unique Identifier for Patient: first name, last name and birth date

 

Now I am facing the problem that how would i check this condition from the database. if i go for soql query one by one for every inserting record than surly i will face soql execution limits.

 

Please suggest, if any one have any idea to achieve this functionality

 

Thanks in advance!!

 

  • March 14, 2010
  • Like
  • 0

Hi All ,

 

I am stuck to impliment a logic... below is the requirment,,

i have 3 objects( Leads , 2 custom(Virtual Numbers and Lead Virtuals)

 I have a campaign and in that campaign i have 1000+ leads......

there is button(visualforce button) on campaign( Assign Numbers) , when i click on the the button...

it will search all the leads in the campaign and  for each lead get his Area code(for eg. if Phone no is((408)512-2626) then get the 408)

For each  Area code eg 408 get the virtual number and put that Virtual no into the one of the custom field on lead object(Virtual_Number__c).

Also get each Associated Lead with Virtual no Id's and create a new lead Virtual.

  if a virtual number of a particular Area code is not avialable then than create a task.

 

If i impliment this logic for a single lead that works fine but i am getting hard time as bulk asigning

 

please see the logic below for assigning no to single lead....

 

Lead l2 = [Select Id,Status,Phone,Virtual_Number__c,FCCampaign__c,
                                  Number_type__c,IsProvisioned__c From Lead where Id = :id];
    if(l2.Status != 'New'){
        ReturnCode = 'Lead Status should be New ';
              return null;
    }
    else{
    string temp;
             temp = l2.Phone.substring(0,5);
             temp = temp + '%';
             list<Virtual_Number__c> v1 =    [Select Virtual_Number__c, Virtual_Number_Staus__c, Id
                             From Virtual_Number__c where Virtual_Number__c like :temp
                                      and Virtual_Number_Staus__c = 'Ready to Assign' limit 1];
                      System.debug('After VN Number................' + v1);
         FCCampaign__c F1 = [Select Id,Start_Trial_Date__c from FCCampaign__c where Id = :l2.FCCampaign__c];        
             Lead_Virtual__c vr = new Lead_Virtual__c();                        
                   if (v1.size()>0){
                       l2.Virtual_Number__c = v1[0].Virtual_Number__c;
             l2.Status = 'Trial';
             l2.Provisioning_Status__c = 'Provisioned';
           //  l2.Active__c = true;
             l2.Start_Trial_Date__c = F1.Start_Trial_Date__c;
             l2.IsProvisioned__c = true;
            // l2.End_Trial_Date__c = System.today()+ 14;
             v1[0].Virtual_Number_Staus__c = 'Assigned';
            
             vr.Lead__c = l2.Id;
             vr.Virtual_Number__c = v1[0].Id;
             vr.Status__c = 'Active';
                  
                   try{
                       update l2;
                       update v1;
                       insert vr;
                       PageReference detailPage = (new ApexPages.StandardController(L1)).view();
                   detailPage.setRedirect(true);
                   return detailPage; 
                   }catch(exception e){
                       System.debug('Error:' +e);
                       Returncode = 'SFDC Error:' +e;
                       return null;
                   }}
                   else{
             ReturnCode = 'Virtual Number is not available for lead area code: Please contact Twilio';
             l2.Provisioning_Status__c = 'Pending';
             update l2;
              return null;
                   }
}
    }
public PageReference okay(){
        PageReference detailPage = (new ApexPages.StandardController(L1)).view();
     detailPage.setRedirect(true);
     return detailPage;
   
    }
}

 

Creating task is not impliment till now in above code

Here chalanges in bulk assigning  are that how to track each with virtual number with the lead and also how to create lead virtuals with the particular lead and virtual number.

If i take leads in a list and loop the virtual number with particular area code then it will cross the SOQL limits.

I want to implimnet logic in such a way that i can update approx 800 in a time in 1 shot( as i can use @future in my class)

 

Any help  will be appriciated

 

Thanks

  • February 09, 2010
  • Like
  • 0

Hi All ,

 

I am stuck to impliment a logic... below is the requirment,,

i have 3 objects( Leads , 2 custom(Virtual Numbers and Lead Virtuals)

 I have a campaign and in that campaign i have 1000+ leads......

there is button(visualforce button) on campaign( Assign Numbers) , when i click on the the button...

it will search all the leads in the campaign and  for each lead get his Area code(for eg. if Phone no is((408)512-2626) then get the 408)

For each  Area code eg 408 get the virtual number and put that Virtual no into the one of the custom field on lead object(Virtual_Number__c).

Also get each Associated Lead with Virtual no Id's and create a new lead Virtual.

  if a virtual number of a particular Area code is not avialable then than create a task.

 

If i impliment this logic for a single lead that works fine but i am getting hard time as bulk asigning

 

please see the logic below for assigning no to single lead....

 

Lead l2 = [Select Id,Status,Phone,Virtual_Number__c,FCCampaign__c,
                                  Number_type__c,IsProvisioned__c From Lead where Id = :id];
    if(l2.Status != 'New'){
        ReturnCode = 'Lead Status should be New ';
              return null;
    }
    else{
    string temp;
             temp = l2.Phone.substring(0,5);
             temp = temp + '%';
             list<Virtual_Number__c> v1 =    [Select Virtual_Number__c, Virtual_Number_Staus__c, Id
                             From Virtual_Number__c where Virtual_Number__c like :temp
                                      and Virtual_Number_Staus__c = 'Ready to Assign' limit 1];
                      System.debug('After VN Number................' + v1);
         FCCampaign__c F1 = [Select Id,Start_Trial_Date__c from FCCampaign__c where Id = :l2.FCCampaign__c];        
             Lead_Virtual__c vr = new Lead_Virtual__c();                        
                   if (v1.size()>0){
                       l2.Virtual_Number__c = v1[0].Virtual_Number__c;
             l2.Status = 'Trial';
             l2.Provisioning_Status__c = 'Provisioned';
           //  l2.Active__c = true;
             l2.Start_Trial_Date__c = F1.Start_Trial_Date__c;
             l2.IsProvisioned__c = true;
            // l2.End_Trial_Date__c = System.today()+ 14;
             v1[0].Virtual_Number_Staus__c = 'Assigned';
            
             vr.Lead__c = l2.Id;
             vr.Virtual_Number__c = v1[0].Id;
             vr.Status__c = 'Active';
                  
                   try{
                       update l2;
                       update v1;
                       insert vr;
                       PageReference detailPage = (new ApexPages.StandardController(L1)).view();
                   detailPage.setRedirect(true);
                   return detailPage; 
                   }catch(exception e){
                       System.debug('Error:' +e);
                       Returncode = 'SFDC Error:' +e;
                       return null;
                   }}
                   else{
             ReturnCode = 'Virtual Number is not available for lead area code: Please contact Twilio';
             l2.Provisioning_Status__c = 'Pending';
             update l2;
              return null;
                   }
}
    }
public PageReference okay(){
        PageReference detailPage = (new ApexPages.StandardController(L1)).view();
     detailPage.setRedirect(true);
     return detailPage;
   
    }
}

 

Creating task is not impliment till now in above code

Here chalanges in bulk assigning  are that how to track each with virtual number with the lead and also how to create lead virtuals with the particular lead and virtual number.

If i take leads in a list and loop the virtual number with particular area code then it will cross the SOQL limits.

I want to implimnet logic in such a way that i can update approx 800 in a time in 1 shot( as i can use @future in my class)

 

Any help  will be appriciated

 

Thanks

  • February 09, 2010
  • Like
  • 0

Hi All,

 

I am updating opportunities while updating the Account Owner.

 

Opportunities are more than 100 , so i divided into batches of 50 

 

but i am still getting the DML execption while updating 300 records ( max DML satatements should be 6)

 

\Error: Apex trigger PAMUpdate caused an unexpected exception, contact your administrator: PAMUpdate: execution of BeforeUpdate caused by: System.Exception: Too many DML rows: 147: Trigger.PAMUpdate: line 63, column 5

 

 Here is my complete snipped of code

 

trigger PAMUpdate on Account (before update) {

    Map <Id, String> acc = new Map <Id, String>();

    List<String> accountList = new List<String>();

    for (Account a : Trigger.new)

    {

        String oppOwner = Trigger.oldMap.get(a.Id).OwnerId;

        if (a.IsPartner == true && a.OwnerId != oppOwner)

        {           

            accountList.add(a.Id);

        }

    }
  //  System.debug(' Accounts are ' + accountList );
   // System.debug(' Account Size is =  ' + accountList.size() );
 
   
 List<Opportunity> oppList = new List<Opportunity>();

    if(accountList.size()>0)

    {  

        oppList  = [select PAM__c,PartnerAccountId from Opportunity

                                     where PartnerAccountId In : accountList limit 300];

        }
        for(Opportunity oppRec:smileysurprised:ppList)

        {

            oppRec.PAM__c = Trigger.newMap.get(oppRec.PartnerAccountId).OwnerId;

        }

       
 if(oppList.size() > 50){
       List<Opportunity> subList = new List<Opportunity>();

for(Opportunity record : oppList){

subList.add(record);

if(subList.size()==49){

try{
    update subList;  }
    catch(Exception ex){
            System.debug(' Exception Occured' + ex);}
subList.clear();
}
}
if(subList.size() > 0){

try{
    update subList;  }
    catch(Exception ex){
            System.debug(' Exception Occured' + ex);}
}

}else{

try{
    update oppList;  }
    catch(Exception ex){
            System.debug(' Exception Occured' + ex);}

} }

 

Please suggest if i am doing any thing wrong while updating .

 

Thanks in advance

  • December 21, 2009
  • Like
  • 0

Hi All,

 

I am updating opportunities while updating the Account Owner.

 

Opportunities are more than 100 , so i divided into batches of 50 

 

but i am still getting the DML execption while updating 300 records ( max DML satatements should be 6)

 

\Error: Apex trigger PAMUpdate caused an unexpected exception, contact your administrator: PAMUpdate: execution of BeforeUpdate caused by: System.Exception: Too many DML rows: 147: Trigger.PAMUpdate: line 63, column 5

 

 Here is my complete snipped of code

 

trigger PAMUpdate on Account (before update) {

    Map <Id, String> acc = new Map <Id, String>();

    List<String> accountList = new List<String>();

    for (Account a : Trigger.new)

    {

        String oppOwner = Trigger.oldMap.get(a.Id).OwnerId;

        if (a.IsPartner == true && a.OwnerId != oppOwner)

        {           

            accountList.add(a.Id);

        }

    }
  //  System.debug(' Accounts are ' + accountList );
   // System.debug(' Account Size is =  ' + accountList.size() );
 
   
 List<Opportunity> oppList = new List<Opportunity>();

    if(accountList.size()>0)

    {  

        oppList  = [select PAM__c,PartnerAccountId from Opportunity

                                     where PartnerAccountId In : accountList limit 300];

        }
        for(Opportunity oppRec:oppList)

        {

            oppRec.PAM__c = Trigger.newMap.get(oppRec.PartnerAccountId).OwnerId;

        }

       
 if(oppList.size() > 50){
       List<Opportunity> subList = new List<Opportunity>();

for(Opportunity record : oppList){

subList.add(record);

if(subList.size()==49){

try{
    update subList;  }
    catch(Exception ex){
            System.debug(' Exception Occured' + ex);}
subList.clear();
}
}
if(subList.size() > 0){

try{
    update subList;  }
    catch(Exception ex){
            System.debug(' Exception Occured' + ex);}
}

}else{

try{
    update oppList;  }
    catch(Exception ex){
            System.debug(' Exception Occured' + ex);}

} }

 

Please suggest if i am doing any thing wrong while updating .

 

Thanks in advance

  • December 21, 2009
  • Like
  • 0

I am writing a simple VF template 

 

Getting an error while saving ( Error: Invalid field Opportunity_Rebate__r for SObject Opportunity)

 Opportunity_Rebate is a custom related list and Master Detail with the Opportunity

i have tried all the options(Opportunity_Rebate__c ,Opportunity_Rebates__c,Opportunity_Rebates__r,Opportunity_Rebate__r)

 

<messaging:emailTemplate subject="testing"
recipientType="Contact"
relatedToType="Opportunity"
subject="Rebates for opportunities: {!relatedTo.name}">

<messaging:smileytongue:lainTextEmailBody >
Dear {!recipient.name},
 
Below is a list of Opportunities Rebates related to Opportunity: {!relatedTo.name}

              [ Discount ] - [ Subject ] - [ Email ] - [ Status ]
<apex:repeat var="cx" value="{!relatedTo.Opportunity__Rebate__r}">
              [ {!cx.Discount__c} ]

</apex:repeat>

</messaging:smileytongue:lainTextEmailBody>
</messaging:emailTemplate>

 

Any suggetions!!Do i need to add somting else

 

Thnaks

  • December 17, 2009
  • Like
  • 0

I am writing a simple VF template 

 

Getting an error while saving ( Error: Invalid field Opportunity_Rebate__r for SObject Opportunity)

 Opportunity_Rebate is a custom related list and Master Detail with the Opportunity

i have tried all the options(Opportunity_Rebate__c ,Opportunity_Rebates__c,Opportunity_Rebates__r,Opportunity_Rebate__r)

 

<messaging:emailTemplate subject="testing"
recipientType="Contact"
relatedToType="Opportunity"
subject="Rebates for opportunities: {!relatedTo.name}">

<messaging:plainTextEmailBody >
Dear {!recipient.name},
 
Below is a list of Opportunities Rebates related to Opportunity: {!relatedTo.name}

              [ Discount ] - [ Subject ] - [ Email ] - [ Status ]
<apex:repeat var="cx" value="{!relatedTo.Opportunity__Rebate__r}">
              [ {!cx.Discount__c} ]

</apex:repeat>

</messaging:plainTextEmailBody>
</messaging:emailTemplate>

 

Any suggetions!!Do i need to add somting else

 

Thnaks

  • December 17, 2009
  • Like
  • 0

Hi All,

 

I am trying to upload file through Rest API. i am able to upload and extract text files properly but if i upload any other file format (pdf,doc ,ppt or any image) , the file uploads fine but if i try to open that file it won't open( error message : file is broken , or the pdf is blank). It seems the file body i am sending is not properly encoded for other file formats.

Below is my code which i am using to upload files

*****************************************************
String ObjectName = input.filename;
System.debug('ObjectName' + ObjectName);
Blob BodyContent=input.fileBody;
String DocBody = BodyContent.toString();
// String DocBody = EncodingUtil.base64Encode(BodyContent);
// String DocBody = EncodingUtil.urlEncode(bodyContent.toString(), 'UTF-8');
// String DocBody1 =
System.debug('DocBody' + DocBody);
Integer bodyLength =DocBody.length();
System.debug('bodyLength ------------->' + bodyLength );

String url6=input.StorageURL;
Http h6 = new Http();

HttpRequest req6 = new HttpRequest();
req6.setTimeout(60000);
req6.setEndpoint(url6 + '/' + input.containerName + '/'+input.objectPath + '/' + ObjectName );//
System.debug(url6);
req6.setMethod('PUT');

req6.setHeader('X-Auth-Token',input.AuthToken);
req6.setHeader('Content-Type','application/octet-stream');
req6.setHeader('Content-Length',string.valueof(bodyLength));
req6.setHeader('X-Object-Meta-PIN','1234');
// System.debug('Request object is----------->' + req6);
req6.setBody(DocBody);
HttpResponse res6;
res6 = h6.send(req6);
*************************************************
if i upload a file directly to storage size is 15Kb but if i upload through API file size is showing 24 KB.

Please let me know do i need to encode the file body or am i missing any thing.

I have tried with encloding also but still no luck


Quick response would be appreciated!!

  • September 14, 2010
  • Like
  • 0

Hi All,

 

i have saved a file to some third party sever. I am making an APi call retriving the file and below is the response

 

HTTP/1.1 200 Ok
Date: Wed, 11 Jul 2007 19:37:41 GMT
Server: Apache
Last-Modified: Fri, 12 Jun 2007 13:40:18 GMT
ETag: b0dffe8254d152d8fd28f3c5e0404a10
Content-type: text/html
Content-Length: 512000
[ ... ]  (file content)

 

Now i need to create a link (view ) in vf page, so when a  user click this link he should be able to download the file(same view functionality in document or we can say save as functionality).

 

Please let me know, Do i need to bulid the file again or Is there quick java script where i can pass all these values and it will take care rest.

 

Thanks in Advance!!

  • September 08, 2010
  • Like
  • 0

Hi All,

 

i want to display dependent and controlling piclklist in Vf page.

i have tried using slect list and selct option but it showing all the value and i have read that Input fields are currently not supported dependent picklists.

i also dont want to hard code the values in the controller as it might change in future.

Is there any way i can make this as genric using describe or any workaround?

 

Thanks in advance

 

  • May 20, 2010
  • Like
  • 0

Hi All,

 

i got stuck writing an action handler.

 

I have some custom components and a visual for page , below is my code

 

<apex:page contentType="text/xml" showHeader="false" controller="DialMerchant">
    <Response>
    <Say>Hello, The number you have reached is in service and dialing merchant</Say>
        <Dial record="true" action="http://abcd-developer-edition.na7.force.com/Status">{!$CurrentPage.parameters.Called}</Dial>
    </Response>
</apex:page>

 

when this page is called it palays the message in <Say> and Dial the number mentioned in {!$CurrentPage.parameters.Called}.

Now after the call completes according to the telephonic developer they send the Status of call on the Action element specified in Dial Component which could be a Absolute or relative URL.

 

But it seems my vf page Status is never called.

 

how can i make sure if i am getting any POST request on the URL ( how to print debug or POST request as i have tried to put some debug in controller and never called).

 

Any comments will much appricieated.

 

Thanks in Advance

  • April 29, 2010
  • Like
  • 0

How to create a HyperLink Formula on thr phone which will call my genric visual force page

 

Thanks in advance

  • April 16, 2010
  • Like
  • 0

Hi All,

 

I am getting hard time to create a link on a phone number. Actually i want to implement click to call functionality with some telephony company.

 

Now i want to right a generic visual force page which can be embedded in all the objects as a page layout or some kind of JavaScript which can create a link on all the phone numbers and which in turn call my visualforce page on clicking that number. I wanted to implement on all the phone numbers present in the org (For e.g. how skype is doing right noe).One more thing I don’t have any CTI.

 

Is there any way to achieve this? Please let me know if any one implemented this kind of functionality before.

 

Thanks in advance.

 

  • April 16, 2010
  • Like
  • 0

Hi All,

 

I am getting hard time to create a link on a phone number. Actually i want to implement click to call functionality with some telephony company.

 

Now i want to right a generic visual force page which can be embedded in all the objects as a page layout or some kind of JavaScript which can create a link on all the phone numbers and which in turn call my visualforce page on clicking that number. I wanted to implement on all the phone numbers present in the org (For e.g. how skype is doing right noe).One more thing I don’t have any CTI.

 

Is there any way to achieve this? Please let me know if any one implemented this kind of functionality before.

 

Thanks in advance.

 

  • April 16, 2010
  • Like
  • 0

Hi All,

 

i have written a trigger on campaign and which calls a future method when the campign is close. but i am getting the below error

 

Failed to invoke future method 'public static void updateLead(LIST:String)'

caused by: System.Exception: Too many callouts: 11

Class.TwilioRestClient.

request: line 70, column 32
Class.CommonUpdateUrl.UpdateOutOfServiceUrl: line 62, column 14
Class.CampClosed.updateLead: line 91, column 8
External entry point
below is the my class
public with sharing class CampClosed {

@future(callout=true)
public static void updateLead(List<String> CampaignList){

List<Lead> LeadToUnassign = new List<Lead>();
List<String> VN = new List<String>();
list<String> ListIds = new list<String>();
list<String> UpdateURL = new list<String>();
list<Lead_Virtual__c> vnn = new list<Lead_Virtual__c>();
if(CampaignList.size()>0)

    {   
        list<lead> Checklist = new list<Lead>();
        Checklist = [Select Id from Lead where FCCampaign__c In :CampaignList and Status ='Trial'limit 10];
        if(Checklist.size()>0){
          list<Twilio_URL__c> t1 = [select Id,Name,URL_Value__c from Twilio_URL__c  where Name = 'Out Of Service' limit 1];
        System.debug('Before Lead');
for(list<Lead> l1: [Select Id,Status,Phone,Virtual_Number__c,FCCampaign__c,Actual_End_Date__c,IsProvisioned__c,
                    (Select Id, Status__c From Lead_Virtuals__r) from Lead where FCCampaign__c In :CampaignList and Status ='Trial']) {
       for(Lead l2 :l1){
       VN.add(l2.Virtual_Number__c);
       l2.Status = 'Cancel';
       l2.Provisioning_Status__c ='Pending';
      l2.Virtual_Number__c= '';
      l2.Actual_End_Date__c= System.today();
      l2.IsProvisioned__c = false;                          
         LeadToUnassign.add(l2);
        ListIds.add(l2.Id);
       }
    //   for(Lead_Virtual__c temp :l1.Lead_Virtuals__r){
      //         temp.Status__c = 'Inactive';
        //     vnn.add(temp);
      // }
         if (LeadToUnassign.size() == 200) {
        //  for(Virtual_Number__c v1 :)
            try {
                list<Lead_Virtual__c> vr1 = [Select Id,Status__c from Lead_Virtual__c where Lead__c IN :ListIds
                                                                        and Status__c = 'Active'];
                List<Virtual_Number__c> V1 = new List<Virtual_Number__c>();
                V1 =[Select Id,Virtual_Number__c,SID__c,Twilio_URL__c from Virtual_Number__c where Virtual_Number__c IN :VN];
                for(Virtual_Number__c v2 :V1){
                    v2.Virtual_Number_Staus__c = 'Hold';
                    v2.Twilio_URL__c =t1[0].Id;
                    UpdateURL.add(v2.SID__c);
                }
                
                for(Lead_Virtual__c vr2 :vr1){
                    vr2.Status__c = 'Inactive';
                }
                System.debug('Before Update');
                if(UpdateURL.size()>=600){
                    CommonUpdateUrl.UpdateOutOfServiceUrl(UpdateURL);
                    UpdateURL.clear();
                }
                update LeadToUnassign;
                update V1;
                update vr1;
                System.debug('After Update');
                LeadToUnassign.clear();
                VN.clear();
                ListIds.clear();
            //  PassUpadateURLParametes.PassParameter(UpdateURL);
            

            } catch(Exception ex) {
                System.debug(' Exception Occured' + ex);     
            //  sentEmail(i);  
                LeadToUnassign.clear();
                VN.clear();
                ListIds.clear();    
            }                                           
       }  
                                 }                                              
    if (! LeadToUnassign.isEmpty()) {
        try {
            System.debug('2nd  if statement');
            list<Lead_Virtual__c> vr1 = [Select Id,Status__c from Lead_Virtual__c where Lead__c IN :ListIds
                                                                    and Status__c = 'Active'];
            List<Virtual_Number__c> V1 = new List<Virtual_Number__c>();
                V1 =[Select Id,Virtual_Number__c,SID__c,Twilio_URL__c from Virtual_Number__c where Virtual_Number__c IN :VN];
                for(Virtual_Number__c v2 :V1){
                    v2.Virtual_Number_Staus__c = 'Hold';
                    v2.Twilio_URL__c =t1[0].Id;
                    UpdateURL.add(v2.SID__c);
                }
                for(Lead_Virtual__c vr2 :vr1){
                    vr2.Status__c = 'Inactive';
                }
            if(!UpdateURL.isEmpty()){
                CommonUpdateUrl.UpdateOutOfServiceUrl(UpdateURL);
            }
                            update LeadToUnassign;
                update V1;
                update vr1;
            //  update VN;
            LeadToUnassign.clear();
                VN.clear();
        } catch(Exception ex) {
            System.debug(' Exception Occured' + ex);
        //  sentEmail(i);
        
        }
    }      
                                       }       
      else{
        System.debug('No Lead is Active');
           }                                                                            
                                       }                                        
    }
}
Please suggest how i can get over from this problem.
Thanks,

  • April 06, 2010
  • Like
  • 0

Hi All ,

 

I am stuck to impliment a logic... below is the requirment,,

i have 3 objects( Leads , 2 custom(Virtual Numbers and Lead Virtuals)

 I have a campaign and in that campaign i have 1000+ leads......

there is button(visualforce button) on campaign( Assign Numbers) , when i click on the the button...

it will search all the leads in the campaign and  for each lead get his Area code(for eg. if Phone no is((408)512-2626) then get the 408)

For each  Area code eg 408 get the virtual number and put that Virtual no into the one of the custom field on lead object(Virtual_Number__c).

Also get each Associated Lead with Virtual no Id's and create a new lead Virtual.

  if a virtual number of a particular Area code is not avialable then than create a task.

 

If i impliment this logic for a single lead that works fine but i am getting hard time as bulk asigning

 

please see the logic below for assigning no to single lead....

 

Lead l2 = [Select Id,Status,Phone,Virtual_Number__c,FCCampaign__c,
                                  Number_type__c,IsProvisioned__c From Lead where Id = :id];
    if(l2.Status != 'New'){
        ReturnCode = 'Lead Status should be New ';
              return null;
    }
    else{
    string temp;
             temp = l2.Phone.substring(0,5);
             temp = temp + '%';
             list<Virtual_Number__c> v1 =    [Select Virtual_Number__c, Virtual_Number_Staus__c, Id
                             From Virtual_Number__c where Virtual_Number__c like :temp
                                      and Virtual_Number_Staus__c = 'Ready to Assign' limit 1];
                      System.debug('After VN Number................' + v1);
         FCCampaign__c F1 = [Select Id,Start_Trial_Date__c from FCCampaign__c where Id = :l2.FCCampaign__c];        
             Lead_Virtual__c vr = new Lead_Virtual__c();                        
                   if (v1.size()>0){
                       l2.Virtual_Number__c = v1[0].Virtual_Number__c;
             l2.Status = 'Trial';
             l2.Provisioning_Status__c = 'Provisioned';
           //  l2.Active__c = true;
             l2.Start_Trial_Date__c = F1.Start_Trial_Date__c;
             l2.IsProvisioned__c = true;
            // l2.End_Trial_Date__c = System.today()+ 14;
             v1[0].Virtual_Number_Staus__c = 'Assigned';
            
             vr.Lead__c = l2.Id;
             vr.Virtual_Number__c = v1[0].Id;
             vr.Status__c = 'Active';
                  
                   try{
                       update l2;
                       update v1;
                       insert vr;
                       PageReference detailPage = (new ApexPages.StandardController(L1)).view();
                   detailPage.setRedirect(true);
                   return detailPage; 
                   }catch(exception e){
                       System.debug('Error:' +e);
                       Returncode = 'SFDC Error:' +e;
                       return null;
                   }}
                   else{
             ReturnCode = 'Virtual Number is not available for lead area code: Please contact Twilio';
             l2.Provisioning_Status__c = 'Pending';
             update l2;
              return null;
                   }
}
    }
public PageReference okay(){
        PageReference detailPage = (new ApexPages.StandardController(L1)).view();
     detailPage.setRedirect(true);
     return detailPage;
   
    }
}

 

Creating task is not impliment till now in above code

Here chalanges in bulk assigning  are that how to track each with virtual number with the lead and also how to create lead virtuals with the particular lead and virtual number.

If i take leads in a list and loop the virtual number with particular area code then it will cross the SOQL limits.

I want to implimnet logic in such a way that i can update approx 800 in a time in 1 shot( as i can use @future in my class)

 

Any help  will be appriciated

 

Thanks

  • February 09, 2010
  • Like
  • 0

Hi All,

 

I am updating opportunities while updating the Account Owner.

 

Opportunities are more than 100 , so i divided into batches of 50 

 

but i am still getting the DML execption while updating 300 records ( max DML satatements should be 6)

 

\Error: Apex trigger PAMUpdate caused an unexpected exception, contact your administrator: PAMUpdate: execution of BeforeUpdate caused by: System.Exception: Too many DML rows: 147: Trigger.PAMUpdate: line 63, column 5

 

 Here is my complete snipped of code

 

trigger PAMUpdate on Account (before update) {

    Map <Id, String> acc = new Map <Id, String>();

    List<String> accountList = new List<String>();

    for (Account a : Trigger.new)

    {

        String oppOwner = Trigger.oldMap.get(a.Id).OwnerId;

        if (a.IsPartner == true && a.OwnerId != oppOwner)

        {           

            accountList.add(a.Id);

        }

    }
  //  System.debug(' Accounts are ' + accountList );
   // System.debug(' Account Size is =  ' + accountList.size() );
 
   
 List<Opportunity> oppList = new List<Opportunity>();

    if(accountList.size()>0)

    {  

        oppList  = [select PAM__c,PartnerAccountId from Opportunity

                                     where PartnerAccountId In : accountList limit 300];

        }
        for(Opportunity oppRec:smileysurprised:ppList)

        {

            oppRec.PAM__c = Trigger.newMap.get(oppRec.PartnerAccountId).OwnerId;

        }

       
 if(oppList.size() > 50){
       List<Opportunity> subList = new List<Opportunity>();

for(Opportunity record : oppList){

subList.add(record);

if(subList.size()==49){

try{
    update subList;  }
    catch(Exception ex){
            System.debug(' Exception Occured' + ex);}
subList.clear();
}
}
if(subList.size() > 0){

try{
    update subList;  }
    catch(Exception ex){
            System.debug(' Exception Occured' + ex);}
}

}else{

try{
    update oppList;  }
    catch(Exception ex){
            System.debug(' Exception Occured' + ex);}

} }

 

Please suggest if i am doing any thing wrong while updating .

 

Thanks in advance

  • December 21, 2009
  • Like
  • 0

Hi All,

 

I am updating opportunities while updating the Account Owner.

 

Opportunities are more than 100 , so i divided into batches of 50 

 

but i am still getting the DML execption while updating 300 records ( max DML satatements should be 6)

 

\Error: Apex trigger PAMUpdate caused an unexpected exception, contact your administrator: PAMUpdate: execution of BeforeUpdate caused by: System.Exception: Too many DML rows: 147: Trigger.PAMUpdate: line 63, column 5

 

 Here is my complete snipped of code

 

trigger PAMUpdate on Account (before update) {

    Map <Id, String> acc = new Map <Id, String>();

    List<String> accountList = new List<String>();

    for (Account a : Trigger.new)

    {

        String oppOwner = Trigger.oldMap.get(a.Id).OwnerId;

        if (a.IsPartner == true && a.OwnerId != oppOwner)

        {           

            accountList.add(a.Id);

        }

    }
  //  System.debug(' Accounts are ' + accountList );
   // System.debug(' Account Size is =  ' + accountList.size() );
 
   
 List<Opportunity> oppList = new List<Opportunity>();

    if(accountList.size()>0)

    {  

        oppList  = [select PAM__c,PartnerAccountId from Opportunity

                                     where PartnerAccountId In : accountList limit 300];

        }
        for(Opportunity oppRec:oppList)

        {

            oppRec.PAM__c = Trigger.newMap.get(oppRec.PartnerAccountId).OwnerId;

        }

       
 if(oppList.size() > 50){
       List<Opportunity> subList = new List<Opportunity>();

for(Opportunity record : oppList){

subList.add(record);

if(subList.size()==49){

try{
    update subList;  }
    catch(Exception ex){
            System.debug(' Exception Occured' + ex);}
subList.clear();
}
}
if(subList.size() > 0){

try{
    update subList;  }
    catch(Exception ex){
            System.debug(' Exception Occured' + ex);}
}

}else{

try{
    update oppList;  }
    catch(Exception ex){
            System.debug(' Exception Occured' + ex);}

} }

 

Please suggest if i am doing any thing wrong while updating .

 

Thanks in advance

  • December 21, 2009
  • Like
  • 0