• jaxdmaster
  • NEWBIE
  • 50 Points
  • Member since 2011

  • Chatter
    Feed
  • 2
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 27
    Questions
  • 18
    Replies

Hi,

 

I want to create a picklist with the data from the database. How can i create it?

  • January 05, 2012
  • Like
  • 0

Is it best to check for NULL or allow an exception to fired?  For example would you use this...

 

if ( somevariable == NULL ) {

   // do something

} else {

  // do something

}

 

Or would you do this...

 

try {

    somevariable = anothervariable.length();

 

} catch ( Exception e )  {

   // catch the error from the erro that occurs from the length check above

}

 

 

 

I want to say the first approach is the best because I always thought it was best prevent an error if possible and when it is not possible use Exception to catch it.  What say you?  I just want to do the best approach when it comes to coding.

 

 

Hi Guys,

 

I'm facing a wierd problem. I've a code which shows 6MB(max limit) of heap size in debug logs and when I moved same code to another org it shows 3MB. I don't know why this is happening. Both the orgs are partner developer org. Does anybody has idea about this?

 

 

Thanks

Hi All,

 

I have a record R1 in which there is a field called description which needs to updated from a value computed  from web-service call. To accomplish this I created an apex batch in which I pass R1 record Id. There in batch I call web-service and parse out xml and get the desire value. Now in execute method after all computations I do following:

 

R1.desc = value;

update R1;

 

But this throws an error to avoid this I've used try catch block. Everthing fine but value doesnt get updated in R1. What is I am missing?

 

Thanks

Hi All,

 

I've several batch in a single batch job. And whenever an error occurs in any batch, salesforce sends an error email to admin. But that email doesnot have enough info about error, so I want to send email using apex code. I will write email sending code catch block in execute method of batch apex. Pls tell me so far I am ok? Now my question is what are the limitations on email in apex. I just want to send email to internal users only. Is there any limit on that?

 

 

Thanks

Hi Guys,

 

I've custom VF page which uploads a doc into CRM Content. I successfully did this but when I do this it goes to personal document but I want it to go to a shared lib. How can I do this? Please find my code below:

ContentVersion content = new ContentVersion();
content.versionData = file;
content.title = title;
content.pathOnClient = fileName;
insert content;

 

Hi Guys,

 

I want to have CRM Content Manager on Salesforce Platform License type user. Can I have it?

 

 

 

 

Thanks

Hi,

 

I want searching functionality on top. Currently it comes in left sidebar. When I enable chatter it comes on top. But I dont want to user chatter. How can I go about it? Pls help.

 

 

Thanks

Hi Guys,

 

I've an App developed using Developer Edition. Now I want to put it on AppExchange and also I want to demo application to my customers. I never done that before. So how can I do this. Please tell me the steps.

 

 

Thanks

Hi Guys,

 

I want to have a functionality like when user logs into the system. A pop up should be displayed (I want to use jquery dialog) asking Yes/No and below on that there should be a checkbox saying don't show it next time. How to achieve this? Is there any way to do it?

 

 

Thanks!

 

Hi Guys,

 

I've a url of external image and I want to download it and store it to attachment via apex code itself. Below code I am writing

 

   Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint('http://t0.gstatic.com/images?q=tbn:ANd9GcRbKQv8h5YamhGNCkc5GZg58n2y-rG8Ju7jUGpS_L4CUH6VI7e-gg');
       req.setMethod('GET');
       HttpResponse res = h.send(req);


        
		Attachment attach = new Attachment();
               Blob b=Blob.valueof(res.getBody());

		attach.Body = b;
		attach.Name = String.valueOf('FirstPageImage4.png');
		attach.ContentType = 'image/png';
		attach.ParentId ='a00E0000001Ayk0'; 
		insert attach;

 I've also added URL to remote host. But when run it. Attachment stores well but when i view it screen comes blank. I saw the body field it show something like '7+777+77.....'

 

But when samething i do manually (Downloaded image to desktop and then uploaded it to attachment on particular record)

It works fine.

 

What I am missing?

 

Thanks

 

Hi Guys,

 

What does it mean by Internal Use Only and Externally Available Image when we upload some document.

 

And what happens if i dont check either of  them.

 

 

 

Thanks

Hi Guys,

 

We have two classes System and Datetime in apex. Both provides static now  method. I want to know what is difference between now method from System and Datetime class. I would also like to know broad idea of System class and when to use it?

 

 

 

Thanks

Hi Guys I am having a batch apex below

 


global class AccountSyncBatch implements  Database.Batchable<sObject> {
    String qry;
   
    global AccountSyncBatch (String q) {
        qry = q;
    }

    global Database.QueryLocator start(Database.BatchableContext BC){
        return Database.getQueryLocator(qry);
    }

    global void execute(Database.BatchableContext BC, List<sObject> scope){
        Account acc = null;
        Set<Id> accIds = new Set<Id>();
        Set<String> partIds = new Set<String>();
        for(sObject s : scope) {
            acc = (Account)s;
            accIds.add(acc.id);
            if(acc.RecordType.name == 'Partner Account' && acc.Partner_Id__c != null) {
                partIds.add(acc.Partner_Id__c);
            }
        }
       
        //List<AggregateResult> con_count = [Select AccountId,count(id) from Contact where AccountId IN : accIds group by AccountId];
        Map<Id,Integer> map1 = new Map<Id,Integer>();
        for(AggregateResult ar : [Select AccountId,count(id) total from Contact where AccountId IN : accIds group by AccountId]) {
            map1.put((Id)ar.get('AccountId'), (Integer)ar.get('total'));
        }
       
        Map<Id,Integer> map2 = new Map<Id,Integer>();
        for(AggregateResult ar : [Select AccountId,count(id) total from Case where AccountId IN : accIds group by AccountId]) {
            map2.put((Id)ar.get('AccountId'), (Integer)ar.get('total'));
        }
       
        Map<String,Integer> map3 = new Map<String,Integer>();
        for(AggregateResult ar : [select Partner_Id__c,count(Id) total from Account where RecordType.name = 'Customer Account' and Partner_Id__c IN : partIds group by Partner_Id__c]) {
            map3.put((String)ar.get('Partner_Id__c'), (Integer)ar.get('total'));
        }
       
        System.debug('######################33-'+map3);
       
        for(sObject s : scope) {
            acc = (Account)s;
            acc.Total_Contacts__c = (map1.get(acc.id)==null)?0:map1.get(acc.id);
            acc.Total_Cases__c = (map2.get(acc.id)==null)?0:map2.get(acc.id);
            if(acc.RecordType.name == 'Partner Account' && acc.Partner_Id__c != null) {
                acc.Total_Active_Customers__c = (map3.get(acc.Partner_Id__c)==null)?0:map3.get(acc.Partner_Id__c);
            }
        }
                       
        //List<AggregateResult> case_count = [Select AccountId,count(id) from Contact where AccountId =: acc.id group by AccountId];
        //List<AggregateResult> acc_count = [select Id,count(Id) from Account where RecordType.name = 'Customer Account' and Partner_Id__c =: acc.Partner_id__c group by Id];
        /*acc.Total_Contacts__c = [Select count() from Contact where AccountId =: acc.id];
        acc.Total_Cases__c = [Select count() from Case where AccountId =: acc.id];
        if(acc.RecordType.name == 'Partner Account') {
            acc.Total_Active_Customers__c = [select count() from Account where RecordType.name = 'Customer Account' and Partner_Id__c =: acc.Partner_id__c];
        }*/
       
       
       
       
          update scope;
    }


    global void finish(Database.BatchableContext BC){
   
    }

}

 

 

 

and i run this by using System log

 

String qry = 'select id,Total_Contacts__c,Total_Cases__c,Total_Active_Customers__c,RecordType.name,Partner_id__c from Account';
AccountSyncBatch asb = new AccountSyncBatch(qry);
Database.executeBatch(asb);

 

 

 

But when i look at Apex Jobs it show too many soql exception now i am unable to see where is the prob and how to fix it.

 

 

 

Thanks

Hi Guys,

 

I'm having a pageBlock but it shows line (please see screenshot highlighted in blue). I want to remove so that it look like related list. How can i do that?

 



Hi Guys,

 

I am using inline editing on block table. When i take standard object it works fine. But when i use custom object it doesn't display lookup.

 

Account----->Contacts------->Party__c(custom) ------------- workfine

Inv__c--------->inv2intr__r------->Person__c(Custom)-----------------doesnt work fine

 

 

 

What could be the reason?

 

Hi Guys,

 

Presently look up search only searches on standard name field. I want it to be performed on other custom fields along with standard name field. How can i do this?

 

 

Thanks

Jagdeep

Hi All,

 

I've a custom object in which standard name field is Country Code and a custom field Country Name.

Whenever i use this object as look up it displays standard name field on form after selection. But i want that Country name should also be appended to standard name field. How can i do this?

 

 

Thanks

Jagdeep

Hi Guys,

 

I've created a Approval process of two steps on some object.

1st Step:

Status: New

Completed Date: blank

 

2nd Step:

Status: Approved

Completed Date: 8/8/2011

 

As you can see there is no sense of showing completed date on 1st step as record is not approved. I want to disappear Completed Date field in step 1 and want to visible in step-2. How can I do it?

 

 

Thanks

Hi All,

 

String field = 'name';

Account acc = [select id,name from account limit 1];

acc.field = 'Jon';

 

 

I am running this code. This produces error. I want to have eval(Javascript) like functionaly in Apex. So that I can do something like this eval(acc.field) = 'Jon';

 

Thanks

 

Hi All,

 

I have a custom controller and visualforce page. On that page I have to show lookup for selecting users which belongs standard profile only. I am able to generate lookup but it show users of all profiles. How can fix it?

 

 

Thanks

Hi all,

 

Why below statement is working.

 

Map<Id,Account> mp = new Map<Id,Account>([select name from Account]);

System.debug(mp);

 

I am not selecting Id although code work fine. How is it working?

Hi All,

 

I've just read fundamental book of force.com. There they mentioned about Metadata-driven development. Can somebody put more light on this.

 

 

Cheers,

Jagdeep

I am having issues including this below query in a string.

 

String Query = 'Select Id, Discount__c from item1__c Where Id'+

'IN(Select item1__c,Product__c From Item2__c where'+ 'Product__c >0)'+

'and Id IN(Select Item1__c,Account_Id__c From Item3__c where active__c >0)';

 

Urgent help will be appreciated...Thanks..

 

 

Hi all,

     i have one object called leaves.In this we have to calculate the no of used days quarterly wize.

i.e.,from date,To date two date fields.Based on the from date,to date  two values are entered then no of days obtained.

no.of.days=todate-fromdate+1; and these no of days are calculated based on quarterly wize. Any one can u please help me this.

 

 

Thanks in advance

Hi Guys,

 

I'm facing a wierd problem. I've a code which shows 6MB(max limit) of heap size in debug logs and when I moved same code to another org it shows 3MB. I don't know why this is happening. Both the orgs are partner developer org. Does anybody has idea about this?

 

 

Thanks

Hi,

 

I want to create a picklist with the data from the database. How can i create it?

  • January 05, 2012
  • Like
  • 0

Hi,

 

I am  new to development and need some help.

I have a cutom object  "Payment__c" , this has all payment information related fields like card name, expire_date__c, etc .    I need to pull the fields values and add a month to the expire_date__c field. Below is my code,

 

CODE:

Payment__c[] payment = [Select Name, expire_date__c FROM Payment__c];

String updatedexpire; 

for (Payment__c  temp : payment)

{

 updatedexpire=  temp.expire_date__c.Months(1);

System.debug ('the current value of updatedexpire==> '+updatedexpire );

}

 

The datetype of expire_date__c is Text(4)

When I execute  this piece of code in Anonymous  , it throws an error

"Method does not exist  or incorrect signature:[String].Months(Integer)"

Can anyone please help me.


Hi All,

 

I have a record R1 in which there is a field called description which needs to updated from a value computed  from web-service call. To accomplish this I created an apex batch in which I pass R1 record Id. There in batch I call web-service and parse out xml and get the desire value. Now in execute method after all computations I do following:

 

R1.desc = value;

update R1;

 

But this throws an error to avoid this I've used try catch block. Everthing fine but value doesnt get updated in R1. What is I am missing?

 

Thanks

Hi Guys,

 

I've custom VF page which uploads a doc into CRM Content. I successfully did this but when I do this it goes to personal document but I want it to go to a shared lib. How can I do this? Please find my code below:

ContentVersion content = new ContentVersion();
content.versionData = file;
content.title = title;
content.pathOnClient = fileName;
insert content;

 

Hi Guys,

 

I've an App developed using Developer Edition. Now I want to put it on AppExchange and also I want to demo application to my customers. I never done that before. So how can I do this. Please tell me the steps.

 

 

Thanks

Hi Guys,

 

I want to have a functionality like when user logs into the system. A pop up should be displayed (I want to use jquery dialog) asking Yes/No and below on that there should be a checkbox saying don't show it next time. How to achieve this? Is there any way to do it?

 

 

Thanks!

 

Hello Everyone,

 

What is the best way to implement a keep me login functionality in Force.com sites?

Hi Guys,

 

What does it mean by Internal Use Only and Externally Available Image when we upload some document.

 

And what happens if i dont check either of  them.

 

 

 

Thanks

Is it best to check for NULL or allow an exception to fired?  For example would you use this...

 

if ( somevariable == NULL ) {

   // do something

} else {

  // do something

}

 

Or would you do this...

 

try {

    somevariable = anothervariable.length();

 

} catch ( Exception e )  {

   // catch the error from the erro that occurs from the length check above

}

 

 

 

I want to say the first approach is the best because I always thought it was best prevent an error if possible and when it is not possible use Exception to catch it.  What say you?  I just want to do the best approach when it comes to coding.

 

 

Hi, Racing against a deadline!

 

The code below looks to see if an Order exists. update order rec if it does, else create new order.

 

Need to figure a way to get the sql query out of the loop to reduce the SOQL hits. Kind of feeling limited because of count(*) function in the query. 

 

Any quick fix ideas or feel free to fix the code :),

 

Thanks!

 

trigger CreateOrderRec4  on Opportunity (after update,after insert) {


List<order__C> newOrders = new List<order__c>();
List<order__C> Updatelist = new List<order__c>();

 
for(Opportunity NewOpp: trigger.new) {         
     
oppid = newOpp.ID;
integer orderCount = [select count() from order__C where opportunity__c = NewOpp.id and autocreate__c =True]; 


if (orderCount == 0 )
{
order__c a1 = new order__c();
a1.opportunity__c = newOpp.id;
a1.order_status__c = newopp.stagename;
a1.account__c = newopp.accountid;

a1.autocreate__c = True;
neworders.add(a1);
}

if (orderCount == 1)
{order__c updOrder = [select id,order_status__c
from order__C  where opportunity__c = newOpp.id and autocreate__c=True ];

updOrder.order_status__c = newopp.stagename;
updOrder.account__c = newopp.accountid;
Updatelist.add(updOrder);
}

}

insert neworders;
update updatelist;
}


  • September 22, 2011
  • Like
  • 0

Hi Guys,

 

I'm having a pageBlock but it shows line (please see screenshot highlighted in blue). I want to remove so that it look like related list. How can i do that?

 



Hi Guys,

 

Presently look up search only searches on standard name field. I want it to be performed on other custom fields along with standard name field. How can i do this?

 

 

Thanks

Jagdeep