• Salesforce Hidden Facts
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 5
    Replies

Hi All,

 

Is there any way to test blank values for Integer fileds, for Strings fields

if( Str == '') or Isblank(Str) ...

Any help must be highly appreciated.

Thanks in advance !



Hi,

I have an example of bulk api from bulk api developer guide:

 

http://www.salesforce.com/us/developer/docs/api_asynch/

inside section walkthrough sample code.(in java)

 

But i am not able to access the connection to salesforce due to some proxy settings.How do i pass the proxy settings in the same code.

 

Error while accessing salesforce:

Failed to send request to https://login.salesforce.com/services/Soap/u/26.0

 

Please help

Thanks :)

  • September 26, 2013
  • Like
  • 0

I want all the Notes and Attachment of Contacts getting rolled up in a different custom Objects (Inline Visualforce Section).

 

Right now i am able to roll up the Attachments but the challenge is both notes & Attachment getting rolled up(Since we need to query on two different objects and the result is stored in two different list).

 

So how can i return two different lists to the page block table Section

 

Below is my tried Code:

 

VF Page:

<apex:page showHeader="false" standardController="Household_Group__c" extensions="HouseHoldntesattach"  >
  
            <apex:form id="form" >
         
                  <apex:pageBlock >
                <apex:pageBlockTable value="{!wrapper }" var="tas" id="filteredtasks"  width="100%" >
                <apex:column >
                                        
                </apex:column>
                      
                    <apex:column >
                    <apex:facet name="header">
                    <apex:outputPanel layout="inline">
                        Title
                    </apex:outputPanel>
                    </apex:facet>
                       <apex:outputText value="{!tas.not2.Title }"> </apex:outputText><br/>
                       <apex:outputText value="{!tas.attach2.Name}"> </apex:outputText> 
                </apex:column>
              
            </apex:pageBlockTable>
            
            </apex:pageBlock>
        
</apex:form>
        </apex:page>

 Controller::

public class HouseHoldntesattach{

 
    public List<Note> not1 {get; set;}
    public List<Attachment> attch1 {get; set;}
    public List<MyWrapper> wrapper {get; set;}
    string st;
    public Household_Group__c objhg {get;set;}

    public HouseHoldntesattach(ApexPages.StandardController controller)
    {
    st=System.currentPagereference().getParameters().get('id');
    st = controller.getId();
    objhg = (Household_Group__c )controller.getRecord();

        system.debug('@@@@@@@111111'+st);
        
     list<attachment> attach = new list<attachment>();
   // list<Note> not= new list<Note>();
         list<Household_Member__c> Childmember = new list<Household_Member__c>();
        Childmember =[select id,Member__c from Household_Member__c where Household_Group__c= :st and Incl_in_Rollup__c = true ];//HH MEMBER ID IS STORED HERE
        
        
        list<string> Childmemberids=new list<string>();
        for(Household_Member__c HHacc:Childmember ){
        Childmemberids.add(HHacc.Member__c );
         
        }
        for(contact con:[select id from contact where AccountId in : Childmemberids]){
        Childmemberids.add(con.id);
        }
        if(!Childmemberids.isempty()){
 

 attch1 =[select id,name,LastModifiedDate,CreatedById  from attachment where ParentId in :Childmemberids ];
        not1 =[SELECT Id,LastModifiedDate,Title FROM Note where ParentId in :Childmemberids ];
         wrapper = new List<MyWrapper>() ;
 
           // wrapper.add(new MyWrapper(not1 , attch1 )) ;
    }
    }
       
    public class MyWrapper
    {
        public Note not2{get; set;}
        public Attachment attach2{get; set;}
        
        public MyWrapper(Note not1 , Attachment attch1 )
        {
            not2= not1 ;
            attach2= attch1  ;
        }
    }

              
}

 

 

Thanks in Advance

  • September 26, 2013
  • Like
  • 0

hi i am sending only a single Http Request in Batch but still facing error System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

 

My test code is 

 

@isTest(SeeAllData=true)
static void test1(){
MirrorTestUtil.setupSettings();
User u = [Select Authorize__c From User Where Id = :UserInfo.getUserId()];
u.Authorize__c = true;
update u;
System.debug('u is '+u);

List<FeedItem> feedList= new List<FeedItem>();
for (Integer i = 0; i<5;i++)
feedList.add( new FeedItem(Body='@'+UserInfo.getName()+'Hello World'+i,ParentId = UserInfo.getUserId()));
Test.setMock(HttpCalloutMock.class, new MirrorMockTimelinePostImpl());
Test.startTest();
Test.setMock(HttpCalloutMock.class, new MirrorMockTimelinePostImpl());

insert feedList;
Test.stopTest();
}

 

and My trigger code is 

trigger PostFeedsToTimeLine on FeedItem (after insert) {

BatchPublishTimeLine publishBatch = new BatchPublishTimeLine(Trigger.new,contentMap);
Database.executeBatch(publishBatch,5);
}

 

and My Batch class code is 

public class BatchPublishTimeLine implements Database.Batchable<sObject>{
sObjectIterable iterable;
Map<Id,User> userMap;
Map<String,String> contentmap;

public BatchPublishTimeLine(List<sObject> objectList,Map<String,String> contentmap){
iterable = new sObjectIterable(objectList);
this.userMap = new Map<Id,User>([Select Id,Name From User WHERE Authorize__c = true]);
this.contentmap = contentmap;
}

public Iterable<sObject> start(Database.BatchableContext BC){
return iterable;
}

public void execute(Database.BatchableContext BC, List<sObject> scope){
GMirrorUtil.createTimeLine(scope, contentMap);
}

public void finish(Database.BatchableContext BC){
System.debug('Job Has been Finished');
}
}

 

and My createTimeLine function code is 

 

public static void createTimeLine(List<sObject> objList,Map<String,String> contentMap){

String timelineRes = doApiCall('xyzzz','POST','https://www.googleapis.com/mirror/v1/timeline','xxxxxxxxx');

}

 

doApiCall code is 

public static String doAPICall(String postBody, String method, String endPoint, String accessToken){

HttpRequest req = new HttpRequest();
Http http = new Http();
HttpResponse res;

req.setEndpoint(endPoint);
req.setMethod(method);
req.setHeader('Content-Type','application/json');

if(method == 'POST' || method == 'PUT')
req.setBody(postBody);
req.setHeader('Authorization','Bearer ' + accessToken);
res = http.send(req);
String result = res.getBody();
System.debug('status code is '+res.getStatus());
System.debug('result is'+res.getBody());
return result;
}

 

and the Mock class code response is 

 

@isTest
global class MirrorMockTimelinePostImpl implements HTTPCalloutMock {
global HTTPResponse respond(HTTPRequest req) {
// Optionally, only send a mock response for a specific endpoint
// and method.
System.assertEquals('https://www.googleapis.com/mirror/v1/timeline', req.getEndpoint());
System.assertEquals('POST', req.getMethod());
System.assert(req.getHeader('Authorization').startsWith('Bearer'));

// Create a fake response
HttpResponse res = new HttpResponse();
res.setHeader('Content-Type', 'application/json');
res.setBody('{"kind":"mirror#timelineItem", "id":"mockid", "created":"2013-07-31T12:07:34.882Z", "updated":"2013-07-31T12:07:34.882Z", "etag":"\\"ZECOuWdXUAqVdpmYErDm2-91GmY/NVMWuR8LJyCKttsmne9R4K8n7YI\\"", "text": "New Lead: OauthCheck EarlyAm, Google, Inc., (234) 567-8900"}');
res.setStatusCode(200);
return res;
}
}

 

and i am unable to figure it out how using only one callout its throwing an error ?? Please help

  • September 26, 2013
  • Like
  • 0

Hi,

Please help to create a unit test for my trigger.

 

 

I having a trouble deploying my trigger in productio since sfdc is requiring a unit test. please help me. sandbox do not require a unit test. please please, im clueless onhow to start the unite tes.

 

here's the code:

=====

 

trigger UpdateQuoteManagers on Quote (before insert, before update) {
Set<ID> idOwners = new Set<ID>();


for(Quote quotes:trigger.new)
{
idOwners.add(quotes.Account_Manager__c);
}

if (idOwners.size() > 0)
{
Map<Id,User> users= new Map<Id,User>([Select Territory_Head__c, District_Head__c from User where Id in : idOwners]);

for(Quote qu:trigger.new)
{

if (users.get(qu.Account_Manager__c).Id!= null)
{
qu.District_Head2__c = users.get(qu.Account_Manager__c).District_Head__c;
qu.Territory_Head2__c = users.get(qu.Account_Manager__c).Territory_Head__c;
}
else
{
qu.District_Head2__c = null;
qu.Territory_Head2__c = null;

}
}
}
}