• cloudSavvyProg
  • NEWBIE
  • 175 Points
  • Member since 2016

  • Chatter
    Feed
  • 6
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 55
    Replies
Need help. Using Class below, I have deserialized JSON response however I`m not able to figure out how should I create an account in Salesforce using this deserialized data. Can someone please help?
 
public class candidateParser{
public cls_rut rut;
public class cls_rut {
    public cls_candidates candidates;
}
public class cls_ candidates {
    public cls_candidate [] candidate;
}
public class cls_candidate {
    public String candidate_id; //3
    public String candidate_code;   //AA12
    public String description;  // Steven S.
}
public static candidateParser parse(String json){
    return (candidateParser) System.JSON.deserialize(json, candidateParser.class);
}}

Deserialized JSON:
11:11:02:208 USER_DEBUG [69]|DEBUG|deserializeResults====: candidateParser:[rut=cls_rut:[candidates=cls_candidates:[candidate=(cls_candidate:[candidate_code=AA12, candidate_id=3, description=Steven S.], cls_candidate:[candidate_code= AA13, candidate_id=4, description= Brad Hess], cls_candidate:[candidate_code= AA14, candidate_id=5, description=Brad Jones], cls_candidate:[candidate_code= AA14, candidate_id=6, description=Sample candidate], cls_candidate:[candidate_code= AA16, candidate_id=7, description=ross. k],...)]]]


I`m trying below but I keep getting null response on account name. Please help -
 
candidateParser.cls_candidate deserializeResults2 =     (candidateParser.cls_candidate)JSON.deserialize(replaceJson, candidateParser.cls_candidate.class);    
System.debug('deserializeResults2====: '+deserializeResults2);

Account Acc = New Account ();
Acc.Name =  deserializeResults2.candidate_code;
Insert Acc;

 
In short, my problem is that the Activity History related list on a custom object only shows tasks whose status is Completed. If I create or amend a task so its status is Pending then it does not appear on the list. I would all tasks to show so that people can pick off Pending tasks and complete them. Seems a not unreasonable requirement :-)

To give a bit more information. I was asked add incoming and outgoing email functionaility to a custom object. The outgoing part is easy, using the inbuilt button on the Activity History list. To handle incoming email, I have created an email service which adds tasks to the custom object showing that an email has been received, with the description being the body of the email. The tasks are created successully but only show on the Actiivity History list if their status is Completed. I need them to also show if they have status of Pending, so people can identify them and act on them (typically, reply to the email).

I made the service create tasks, following SF's own documention on incoming email services, but I do wonder if this is the best way. Apart from the above problem, another concern I have is whether tasks will be visible to all revelant users or whether they are private to the creator/assignee.

Maybe I need to take another approach?
Hi,

I have created a custom object named Project_Sheet__c, within that object I have a lookup field to the associated Opportunity.
I want to display a list of the opportunity line items on the Project Sheet page layout.
I'm new to Apex and VF, so spologies if this is an easy thing and I've gone about it all wrong.
The code is compiling ok, but I'm getting the following message on the page 
Content cannot be displayed: SObject row was retrieved via SOQL without querying the requested field: Project_sheet__c.Project_sheet_Opportunity__r

I've tried creating a formula field that returns the OpportunityID, and used that in the query instead, but the error message just changes it's reference to the new field instead.
Any help would be gratefully appreciated.

I have the following for my controller and VF page:

Controller:
public class ProjectSheetOpportunityProductsAP {
    public Project_sheet__c custObj;
        
    public ProjectSheetOpportunityProductsAP(){
                   }
    
    public ProjectSheetOpportunityProductsAP(ApexPages.StandardController controller){
        custObj= (Project_sheet__c)controller.getRecord();
           }
    
    public List<OpportunityLineItem> getOppProducts(){
        List<OpportunityLineItem> lstOLI = [SELECT Quantity,PriceBookEntry.Name FROM OpportunityLineItem WHERE OpportunityID =: custObj.Project_Sheet_Opportunity__r.ID];
        return lstOLI;
    }
    }

VF:
<apex:page standardController="Project_Sheet__c" extensions="ProjectSheetOpportunityProductsAP" showHeader="false" sidebar="false">
    <apex:pageBlock title="Product list">
    <apex:pageblocktable value="{!OppProducts}" var="oli">
        <apex:column value="{!oli.Quantity}"/>
    </apex:pageblocktable>
    </apex:pageBlock>
</apex:page>

I haven't referenced all of the columns in the VF page yet.

Many thanks
I'm trying to use Visualforce charts to show information about from the Contact record associated with the user's User record for the purpose of displaying on our Community.
<apex:page controller="Graph2" >
    <apex:pageblock title="Grr!" >    
        <apex:chart height="250" width="450" animate="true" data="{!pieData}">
        <apex:axis type="Gauge" position="gauge" title="Transaction Load"
            minimum="10" maximum="400" steps="10"/>
        <apex:gaugeSeries dataField="data" donut="50" colorSet="#78c953,#ddd,#0F0" />
        </apex:chart>
    </apex:pageblock>            
</apex:page>
and this Controller:
public with sharing class Graph2
{  
    public List<PieWedgeData> getPieData() 
    {  
        List<PieWedgeData> data = new List<PieWedgeData>();
        List<Contact> memb = new List<Contact>();  

//        String sql = 'SELECT Name, Gauge_Value__c FROM Contact WHERE Id IN (SELECT contactid FROM  user where id = :userinfo.getUserId())';        
        String sql = 'SELECT Name, Gauge_Value__c FROM Contact WHERE Gauge_Value__c != null';
        memb = Database.Query(sql);
        for(Contact temp:memb)
        {           
            data.add(new PieWedgeData(temp.Name,temp.Gauge_Value__c));
        }
        return data;  
    }  
    
    // Wrapper class  
class PieWedgeData 
    {  
        public String name { get; set; }  
        public Decimal data { get; set; } 
        
        public PieWedgeData(String name, Decimal data) 
        {  
            this.name = name;  
            this.data = data;  
 
        }  
    }  
}
displays the chart just fine in the community (the user in question is the only one with a value in Gauge_Value__c), but as soon as I substitute in the commented out line which will return the results for the actual user, I get the following Visualforce Error:

System.QueryException: unexpected token: '(' 
Class.Graph2.getPieData: line 10, column 1

Can anyone suggest what I am doing wrong and/or a different way of doing it?
We have an active "Invoice Manager" in production, now we need to make some changes in it, so we're ready to modify the relevant Apex class in Sandbox first, but before that, we execute the apex test without any modification, and get an error with the origianl apex files. How does it happen as they are active in production in the meantime? Can anybody tell me if something important we've missed?
User-added image

Here is the test file, the log message above shows the error occurs in the line "insert new List<OpportunityLineItem>{testProduct1,testProduct2};", is it the problem of OpportunityLineItem? What should it be?
@isTest (SeeAllData=true)
private class InvoiceManagerTest {
    
    private static Account testAccount;
    private static Opportunity testOpportunity;
    private static Opportunity testEmptyOpportunity;
    private static OpportunityLineItem testProduct1;
    private static OpportunityLineItem testProduct2;
    
    /*
    * init test data
    */
    private static void initData(){
        //init account
        testAccount=new Account(Name='TestAccount', BillingCountry='France');
        insert testAccount;
        //init opportunity
        testOpportunity=new Opportunity(Name='TestOpportunity',stageName='Test',CloseDate=System.today());
        testEmptyOpportunity=new Opportunity(Name='testEmptyOpportunity',stageName='Test',CloseDate=System.today());
        insert new List<Opportunity>{testEmptyOpportunity,testOpportunity};
        
        // create  products
        Product2 p1 = new Product2(Name='Test Product');
        Product2 p2 = new Product2(Name='Test Product');
        insert new List<Product2>{p1,p2};
             
        // Add product to standard pricebook
        // Id taken from Salesforce.com
        String standardPriceBookId ='';
        for(Pricebook2 p:[Select id From Pricebook2 p where isStandard=true limit 1]){
            standardPriceBookId=p.id;
        }
        //System.debug(standardPriceBookId+':'+p1.id);
        PricebookEntry pbe1 = new PricebookEntry(Pricebook2Id=standardPriceBookId, Product2Id=p1.Id,UnitPrice=2,isActive=true);
        insert pbe1;
        PricebookEntry pbe2 = new PricebookEntry(Pricebook2Id=standardPriceBookId, Product2Id=p2.Id,UnitPrice=2,isActive=true);
        insert pbe2;
        
        
        testProduct1 = new OpportunityLineItem(TotalPrice=2 ,Quantity=2 ,PriceBookEntryId=pbe1.Id, OpportunityId=testOpportunity.Id,Ready_to_Invoice__c=true,Invoice__c=null);
        testProduct2 = new OpportunityLineItem(TotalPrice=2,Quantity=2,PriceBookEntryId=pbe1.Id, OpportunityId=testOpportunity.Id,Ready_to_Invoice__c=true,Invoice__c=null);
        insert new List<OpportunityLineItem>{testProduct1,testProduct2};
       
        
    }
    
    /** 
    *   Test method : testGenerateInvoice method covers the logic and expected results
    *   @category Testing Method
    */
    public static testMethod void testGenerateInvoice(){
        initData();
        test.startTest();
          String result1=InvoiceManager.generateInvoice(testEmptyOpportunity.id);
          System.assertNOTEquals(result1,testEmptyOpportunity.id);
          String result2=InvoiceManager.generateInvoice(testOpportunity.id);
        
          System.assertEquals(result2,testOpportunity.id);
          //check invoice
          List<Invoice__c> lstInvoice=[select id, Invoice_Date__c  from Invoice__c where Opportunity__c=:testOpportunity.id];
          System.assertEquals(lstInvoice.isEmpty(),false);
          List<OpportunityLineItem> lstProduct=[select Opportunity.Billing_Entity__C,Ready_to_Invoice__c,Invoice_Date__c,Invoice__c from OpportunityLineItem where id=:testProduct1.id OR id=:testProduct2.id];  
          for(OpportunityLineItem item:lstProduct){
            System.assertEquals(item.Invoice_Date__c,System.today());
            System.assertEquals(item.Invoice__c,lstInvoice.get(0).id);
          }
          
       test.stopTest();     
              
     }   

}

 
Hi All,

I am recieving heap size limit for the below code. I want to send 25000 records as csv via email. 
 
List<Account > acclist = [Select id,name , CreatedDate , lastModifiedDate from Account];
string header = 'Record Id, Name , Created Date, Modified Date \n';
string finalstr = header ;
for(Account a: acclist)
{
 /* Here I am getting heap size limit error*/     
 string recordString = a.id+','+a.Name+','+a.CreatedDate+','+a.LastModifiedDate +'\n';
       finalstr = finalstr +recordString;
}
Messaging.EmailFileAttachment csvAttc = new Messaging.EmailFileAttachment();
blob csvBlob = Blob.valueOf(finalstr);
string csvname= 'Account.csv';
csvAttc.setFileName(csvname);
csvAttc.setBody(csvBlob);
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] toAddresses = new list<string> {'pravinl059@gmail.com'};
String subject ='Account CSV';
email.setSubject(subject);
email.setToAddresses( toAddresses );
email.setPlainTextBody('Account CSV ');
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvAttc});
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

 
I have a custom object trigger that has a logic of sending emails to ids based on criteria. It uses email template and org wide address.

So when the record is inserted, the trigger should send emails. I am not recieving any emails. Any idea how to solve this? 

The code is as follows.

Messaging.SingleEmailMessage mail = Messaging.renderStoredEmailTemplate(emailtemplate.Id, UserInfo.getUserId(), record.Id);
                        List<string> toAddress = new List<string>{"valid address"};
                        mail.setToAddresses(toAddress);
                        mail.setSubject('test');
                        mail.setOrgWideEmailAddressId(owa.Id);
                        mail.setSaveAsActivity(false);
                        mail.setUseSignature(false);
allmsg.add(mail);  
Messaging.sendEmail(allmsg,false);

The above code is in @future method.

Not receiving any emails? how to resolve this?  is there any configuration needs to made in SF?
I have 2 triggers.

1. trigger on parent object
2. trigger on child object

I have a class where I get and set static variables used in these triggers.

From trigger 1 I set the static variable for ex test = 'parent' and get the value of that variable in trigger 2. Works fine in classic.
But in lighning experience, the variable value comes as null in trigger 2 although I set the value in trigger 1.

In my scenerio, trigger 2 is called soon after trigger 1 and I am not using any VF or lighning components. Its a standard page.

So my question is:

Is there way to store the data (like we used static variables in classic) that is available through out that transaction in lightning experience?

Thanks
I am working in service cloud.

I want some data to be displayed from contact when contact is selected(from a loookup field) on new case page. 

I cannot do it as a embedded vf page as I cannot see the embedded page on edit/new case pages.
I cannot override the standard new page to custom vf page as its not want client wants.
I cannot create a formula field as it will not display value in new page.

Is there any other way we could do this? Any suggestion/help is much appreciated.

Thanks

cloudSavvyProg
Hi,

I am Integrating external service with Salesforce dev org using SOAP API WSDL. I am trying to get the data from external service.

I have followed steps through the below link
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_continuation_callout_soap.htm

The WSDL generated is Aysnchronous one which uses System.Continuation as its arguments.

The issue is when i do 
public Object processResponse() {   
      result = stockQuoteFuture.getValue();
       return null;
    }

the getValue() method returns null. So i get null pointer exception on VF page.

I also get 'StockQuoteListResponse_elementFuture:[WebServiceCalloutFuture.label=Continuation-1]' in the debug logs. I am not sure what that means.

Any suggestion will be helpfull.

Thanks



 
I have a custom object trigger that has a logic of sending emails to ids based on criteria. It uses email template and org wide address.

So when the record is inserted, the trigger should send emails. I am not recieving any emails. Any idea how to solve this? 

The code is as follows.

Messaging.SingleEmailMessage mail = Messaging.renderStoredEmailTemplate(emailtemplate.Id, UserInfo.getUserId(), record.Id);
                        List<string> toAddress = new List<string>{"valid address"};
                        mail.setToAddresses(toAddress);
                        mail.setSubject('test');
                        mail.setOrgWideEmailAddressId(owa.Id);
                        mail.setSaveAsActivity(false);
                        mail.setUseSignature(false);
allmsg.add(mail);  
Messaging.sendEmail(allmsg,false);

The above code is in @future method.

Not receiving any emails? how to resolve this?  is there any configuration needs to made in SF?
I have 2 triggers.

1. trigger on parent object
2. trigger on child object

I have a class where I get and set static variables used in these triggers.

From trigger 1 I set the static variable for ex test = 'parent' and get the value of that variable in trigger 2. Works fine in classic.
But in lighning experience, the variable value comes as null in trigger 2 although I set the value in trigger 1.

In my scenerio, trigger 2 is called soon after trigger 1 and I am not using any VF or lighning components. Its a standard page.

So my question is:

Is there way to store the data (like we used static variables in classic) that is available through out that transaction in lightning experience?

Thanks
//@author : Anjum Attar
//Creation Date :
//Modification History :
public with sharing class EmailOppInvoice {
    public Opportunity oppRecord{get;set;}
    public String id{get;set;}
    public String eSubject{get;set;}
    public String eBody{get;set;}
    //public  Contact objcon = new Contact();
    
    public EmailOppInvoice(ApexPages.StandardController controller) {
        oppRecord = (Opportunity)controller.getRecord();
        id = oppRecord.id;
        oppRecord = [Select Id,Name,Email__c,Account.Id From Opportunity Where Id =: id];
        eSubject ='';
        eBody = '';
    }
    
    public EmailOppInvoice() {
    }
    
    public pageReference SendEmail() {
       Messaging.singleEmailMessage email = new Messaging.singleEmailMessage();
       PageReference pdfExample = new pagereference('/apex/OpportunityInvoice?id='+id);  
       pdfExample.setRedirect(true);
        
        Blob content = pdfExample.getContent();
        Messaging.emailFileAttachment fileAttachment = new Messaging.emailFileAttachment();
        fileAttachment.setFileName('Invoice.pdf');
        fileAttachment.setBody(content);
        String[] eAddress = new List<String>();
        try {
            eAddress.add(oppRecord.Email__c);
            email.setSubject(eSubject);
            email.setPlainTextBody(eBody);
            email.setToAddresses(eAddress);
            email.setFileAttachments(new Messaging.EmailFileAttachment[] {fileAttachment});
            Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
            return null;
        }
        catch(Exception e) {
             ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Email Field of Account does not contain any value'));
        }
        return null;
    }
}
Need help. Using Class below, I have deserialized JSON response however I`m not able to figure out how should I create an account in Salesforce using this deserialized data. Can someone please help?
 
public class candidateParser{
public cls_rut rut;
public class cls_rut {
    public cls_candidates candidates;
}
public class cls_ candidates {
    public cls_candidate [] candidate;
}
public class cls_candidate {
    public String candidate_id; //3
    public String candidate_code;   //AA12
    public String description;  // Steven S.
}
public static candidateParser parse(String json){
    return (candidateParser) System.JSON.deserialize(json, candidateParser.class);
}}

Deserialized JSON:
11:11:02:208 USER_DEBUG [69]|DEBUG|deserializeResults====: candidateParser:[rut=cls_rut:[candidates=cls_candidates:[candidate=(cls_candidate:[candidate_code=AA12, candidate_id=3, description=Steven S.], cls_candidate:[candidate_code= AA13, candidate_id=4, description= Brad Hess], cls_candidate:[candidate_code= AA14, candidate_id=5, description=Brad Jones], cls_candidate:[candidate_code= AA14, candidate_id=6, description=Sample candidate], cls_candidate:[candidate_code= AA16, candidate_id=7, description=ross. k],...)]]]


I`m trying below but I keep getting null response on account name. Please help -
 
candidateParser.cls_candidate deserializeResults2 =     (candidateParser.cls_candidate)JSON.deserialize(replaceJson, candidateParser.cls_candidate.class);    
System.debug('deserializeResults2====: '+deserializeResults2);

Account Acc = New Account ();
Acc.Name =  deserializeResults2.candidate_code;
Insert Acc;

 
Hi Experts,

Please help me in mapping out the Account Id from Contact so that I can assign the contact ID to the Opportunity that I created on the Trigger.

Please see code below: 
 
trigger DirectOpp on Direct_Opportunities__c (before insert) {
   
    for (Direct_Opportunities__c d : Trigger.new) {
        date myDate = date.valueOf(system.today());
     
        Opportunity o = new Opportunity();
        o.Name =  ' Direct Opportunity ';
        o.CloseDate = myDate + 7;
        o.StageName = 'New';
        o.OwnerId = d.Assigned_BC__c;
    //  o.AccountId =   I need the account Id here but I was not able to do it
        o.Contact__c = d.Contact__c;
        o.CampaignId = d.Campaign__c;
   
     
        insert o;
        
        Task t = new Task();
        
        t.Subject = 'Subject Type';
        t.ActivityDate = myDate + 1;
	t.Status = 'Not Started';
        t.Priority = 'High';
        t.OwnerId = d.Assigned_BC__c;
        t.WhatId = o.Id;
        
        insert t;
        
        
    }   
}

 
  • August 31, 2016
  • Like
  • 0
Hi ,

I Have one trigger on opportunity on before insert ,before update .In that trigger iam changing owner id on update.Here i need to query the old opportunity team members related to the old owner.But iam not getting opportunity team members.Can any one advise on this.

Regards,
lokesh
Hi,

I am Integrating external service with Salesforce dev org using SOAP API WSDL. I am trying to get the data from external service.

I have followed steps through the below link
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_continuation_callout_soap.htm

The WSDL generated is Aysnchronous one which uses System.Continuation as its arguments.

The issue is when i do 
public Object processResponse() {   
      result = stockQuoteFuture.getValue();
       return null;
    }

the getValue() method returns null. So i get null pointer exception on VF page.

I also get 'StockQuoteListResponse_elementFuture:[WebServiceCalloutFuture.label=Continuation-1]' in the debug logs. I am not sure what that means.

Any suggestion will be helpfull.

Thanks



 
Hi,
Can anyone offer some assistance with this scenario please.
I have a trigger that should be creating one of each custom object(Project_sheet__c and Project_checklist__c) when the opportunity is saved.
Both custom objects have Opporutnity look ups. The trigger was sort of working, but unfortunately I was getting multiple records being created.
I do have workflows on the Opportunity that fire when the opportunity is saved, as well as an additional trigger that creates an asset for each OLI.
I thought the issue was as this trigger is an 'Update' as well as an 'Insert', it was causing it to re-fire.
I've attempted to add a conditional statement that if there is already a Project checklist or Project sheet associated with the Opportunity then it shouldn't create an additional record.
Unfortunately it's not working at all now.
I've highlighted the additional conditional statement in bold that appears to have stopped the trigger working at all.
Any help would be appreciated.

Current trigger:

trigger InsertProjectDocuments on Opportunity (after insert, after update) {
List<Project_sheet_2__C> projSheetToInsert = new List<Project_sheet_2__C>();
List<Project_checklist__c> projChecklistToInsert = new List <Project_checklist__c>();
   
    for(Opportunity opp : Trigger.new) {
        if (opp.IsWon && (opp.Project_sheets_21__r != null) && (opp.project_sheets_21__r != Trigger.oldMap.get(opp.id).Project_sheets_21__r) && (Trigger.oldMap.get(opp.Id).IsWon !=opp.IsWon)) {
            Project_sheet_2__c ps = new Project_sheet_2__c();
            ps.Name = 'Project sheet -' + opp.name;
            ps.PS2_Opportunity__c = opp.id;
            ps.Date_created__c = system.today();  
            ps.Version_Number__c = '1';
            projSheetToInsert.add(ps);            
        }
        if (opp.IsWon && (opp.Project_sheets_2__r != null) && (opp.project_sheets_2__r != Trigger.oldMap.get(opp.id).Project_sheets_2__r) && (Trigger.oldMap.get(opp.Id).IsWon !=opp.IsWon)) {
            Project_checklist__c pc = new Project_checklist__c();
            pc.Name = 'Checklist -' + opp.Name;
            pc.Project_opportunity__c = opp.id;
            projChecklistToInsert.add(pc);
        }
    }
    if(projSheetToInsert.size() >0){
        Database.insert(projSheetToInsert, false);
    }
    if(projChecklistToInsert.size() >0){
    Database.insert(projChecklistToInsert, false);
    }
}
 
Hi All,
I have one field startdate__c which is of type date field when iam using this field in the soql query and displaying that field it is giving the format like : 2016-05-03 00:00:00 .How can i remove 00:00:00 and display only date ? Can someone advise .

Thanks,
Kiran
Hi there,

A colleague created some scheduled jobs and he got notifications about it. He left the company and I deleted his jobs and created them new. Well, I get the notification mail now but still from his email address. Could you help please where I can change that?
Thx
Scenario:I have list button if i select 10 records out of  100 i want to fetch those 10 record id from javascript list button?
I am following a link : http://www.codespokes.com/2013/09/how-to-send-sms-on-mobile-from.html

I am getting error with apex code 
"expecting a left angle bracket, found 'getPersonList' at line 15 column 16"
Can anyone please help on this?
public with sharing class TwilioCloudCommunicationClass {  
  
// Public Properties  
public String SelectedMobileNumber{get;set;}  
public String OtherMobileNumber{get;set;}  
public String textMessage{get;set;}  
  
// Default construtor  
public TwilioCloudCommunicationClass()  
{  
    SelectedMobileNumber  = '' ;  
    OtherMobileNumber = '' ;  
}  
  
Public List getPersonList()  
{  
    Try{  
        List localList = new List();  
        localList.add(new SelectOption('' , '--Select--'));  
        for(contact cont : [select Name,MobilePhone from contact where TwilioRegisteredUser__c = true ])  
        {  
            localList.add(new SelectOption(cont.MobilePhone , cont.Name));            
        }        
        localList.add(new SelectOption('other' , 'Other'));  
        return localList ;  
    }  
    catch(Exception e)  
    {  
        ApexPages.addMessages(e);        
        return null;  
    }  
}  
  
public void SendSMS()  
{  
    Try{        
        SelectedMobileNumber = (SelectedMobileNumber == '')? OtherMobileNumber:SelectedMobileNumber ;  
        if(SelectedMobileNumber != '')  
        {  
            List AdminInfo = TwilioConfig__c.getall().values();  
            String ACCOUNT_SID = '';  
            String AUTH_TOKEN  = '' ;              
            String SenderMobileNumber = '' ;  
            // Informaton getting from custom setting  
            if(AdminInfo.size()>0)  
            {            
                ACCOUNT_SID             = AdminInfo[0].AccountSid__c;  
                AUTH_TOKEN              = AdminInfo[0].AuthToken__c;                  
                SenderMobileNumber      = AdminInfo[0].Admin_Mobile_Number__c;      
            }              
            TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);  
             
            Map properties = new Map {  
                        'To'   => SelectedMobileNumber ,  
                        'From' => SenderMobileNumber,  
                        'Body' => textMessage  
                };  
            TwilioSMS message = client.getAccount().getSmsMessages().create(properties);  
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'Message has been sent'));  
        }  
        else  
        {  
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error, 'Pelase provide valid Mobile Number '));  
        }  
    }catch(Exception e )  
    {  
        ApexPages.addMessages(e);        
        return ;  
    }    
}  
  
}

 
Hi,
I would like to know about the custom setting and is it possible to include the commom fields(CreatedByID
CreatedDate
LastModifiedbyID
Last ModifiedDate
) in all objects in the custom setting?
Is it possible to access the custom setting from the batch apex?
 
In a class syntax what are some things which is bydefault applied on the class if we don't declare them? for ex. with sharing/without sharing which is bydefault applicable on the class? please explain everything comes under the class syntax.
 
how can we make the callouts in batch apex?
In short, my problem is that the Activity History related list on a custom object only shows tasks whose status is Completed. If I create or amend a task so its status is Pending then it does not appear on the list. I would all tasks to show so that people can pick off Pending tasks and complete them. Seems a not unreasonable requirement :-)

To give a bit more information. I was asked add incoming and outgoing email functionaility to a custom object. The outgoing part is easy, using the inbuilt button on the Activity History list. To handle incoming email, I have created an email service which adds tasks to the custom object showing that an email has been received, with the description being the body of the email. The tasks are created successully but only show on the Actiivity History list if their status is Completed. I need them to also show if they have status of Pending, so people can identify them and act on them (typically, reply to the email).

I made the service create tasks, following SF's own documention on incoming email services, but I do wonder if this is the best way. Apart from the above problem, another concern I have is whether tasks will be visible to all revelant users or whether they are private to the creator/assignee.

Maybe I need to take another approach?
Hi,

I have created a custom object named Project_Sheet__c, within that object I have a lookup field to the associated Opportunity.
I want to display a list of the opportunity line items on the Project Sheet page layout.
I'm new to Apex and VF, so spologies if this is an easy thing and I've gone about it all wrong.
The code is compiling ok, but I'm getting the following message on the page 
Content cannot be displayed: SObject row was retrieved via SOQL without querying the requested field: Project_sheet__c.Project_sheet_Opportunity__r

I've tried creating a formula field that returns the OpportunityID, and used that in the query instead, but the error message just changes it's reference to the new field instead.
Any help would be gratefully appreciated.

I have the following for my controller and VF page:

Controller:
public class ProjectSheetOpportunityProductsAP {
    public Project_sheet__c custObj;
        
    public ProjectSheetOpportunityProductsAP(){
                   }
    
    public ProjectSheetOpportunityProductsAP(ApexPages.StandardController controller){
        custObj= (Project_sheet__c)controller.getRecord();
           }
    
    public List<OpportunityLineItem> getOppProducts(){
        List<OpportunityLineItem> lstOLI = [SELECT Quantity,PriceBookEntry.Name FROM OpportunityLineItem WHERE OpportunityID =: custObj.Project_Sheet_Opportunity__r.ID];
        return lstOLI;
    }
    }

VF:
<apex:page standardController="Project_Sheet__c" extensions="ProjectSheetOpportunityProductsAP" showHeader="false" sidebar="false">
    <apex:pageBlock title="Product list">
    <apex:pageblocktable value="{!OppProducts}" var="oli">
        <apex:column value="{!oli.Quantity}"/>
    </apex:pageblocktable>
    </apex:pageBlock>
</apex:page>

I haven't referenced all of the columns in the VF page yet.

Many thanks