• manhnt.bkit
  • NEWBIE
  • 125 Points
  • Member since 2013
  • Salesforce developer/consultant


  • Chatter
    Feed
  • 4
    Best Answers
  • 2
    Likes Received
  • 1
    Likes Given
  • 5
    Questions
  • 20
    Replies
I am trying to get the API Names of a field of a certain object.

For example, I have a field named Testing with an API name of Testing__c.

However when I use 
Set<String> fieldExistingCompare = new Set<String>();

Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Map<String, Schema.SObjectField> fieldMap = schemaMap.get('Request__c').getDescribe().fields.getMap();
Then getting the values via loop like this...
for (String fieldAPINameIN: fieldMap.keySet())
{
              fieldExistingCompare.add(fieldAPINameIN);
}
I get testing__c instead. I need to get the actual API Name of the field with the proper capitalizations.

How do I achieve this? Some people have done it yet I still don't get it.

Your help is deeply appreciated.

Thank you!


Hello everyone,

I need a hand getting 100% code coverage for one of my Apex Classes

The Apex Class:
public class avgCES{

    private final Case cas;

    public double avrgCES{public get; public set;}
    public string CES_Colour{public get; public set;}
    public double count{public get; public set;}

    public avgCES(ApexPages.StandardController controller) {

    this.cas = (Case)Controller.getRecord();
    

if(cas.account.id!=NULL){
    
    List <case> allCase=[Select How_easy_was_it_to_get_the_help_you_need__c from case where accountid=:cas.account.id and How_easy_was_it_to_get_the_help_you_need__c!=NULL];

    double d=0.0;
    integer count=0;
    if(allCase.size()>0){
    for(case c: allCase)
    {
     d+=c.How_easy_was_it_to_get_the_help_you_need__c;
     count++;
    }
    }
    
    
    if(count>0)
    {
        avrgCES=d/count;
    }
    else
    {
        avrgCES=0;
        CES_Colour='Grey';
    }
    
    if(avrgCES<6)
    {
        CES_Colour='Red';
    }
    else if(avrgCES>=6 && avrgCES <=8 )
    {
        CES_Colour='Yellow';
    }
    else
    {
        CES_Colour='Green';
    }
}
}
}

The Test Class
@isTest
public class avgCES_test{
    public static testMethod void testAvgCES() {
        Account a = new Account(name='TestAcc',Reseller_Id__c=12345,Virtualisation_Id__c=1);
        insert a;
        Case c = new Case(subject='Test Case',Account=a,How_easy_was_it_to_get_the_help_you_need__c=6);
        Case c2 = new Case(subject='Test Case2',Account=a,How_easy_was_it_to_get_the_help_you_need__c=5);
        insert c;
        insert c2;
        ApexPages.StandardController sc = new ApexPages.standardController(c);
        avgCES testme = new avgCES(sc);
        testme.avrgCES=5.5;
        testme.CES_Colour='Red';
        
        system.assertEquals(5.5, testme.avrgCES);
        system.assertEquals('Red', testme.CES_Colour);
  }
    
    public static testMethod void testAvgCES2() {
        Account a = new Account(name='TestAcc',Reseller_Id__c=12345,Virtualisation_Id__c=1);
        insert a;
        Case c = new Case(subject='Test Case',Account=a,How_easy_was_it_to_get_the_help_you_need__c=10);
        Case c2 = new Case(subject='Test Case2',Account=a,How_easy_was_it_to_get_the_help_you_need__c=8);
        insert c;
        insert c2;
        ApexPages.StandardController sc2 = new ApexPages.standardController(c);
        avgCES testme = new avgCES(sc2);
        testme.avrgCES=9;
        
        system.assertEquals(9, testme.avrgCES);
        system.assertEquals('Green', testme.CES_Colour);
  }
    
  public static testMethod void testAvgCES3() {
        Account a = new Account(name='TestAcc',Reseller_Id__c=12345,Virtualisation_Id__c=1);
        insert a;
        Case c = new Case(subject='Test Case',Account=a,How_easy_was_it_to_get_the_help_you_need__c=7);
        Case c2 = new Case(subject='Test Case2',Account=a,How_easy_was_it_to_get_the_help_you_need__c=8);
        insert c;
        insert c2;
        ApexPages.StandardController sc3 = new ApexPages.standardController(c);
        avgCES testme = new avgCES(sc3);
        testme.avrgCES=7.5;
    
        testme.CES_Colour='Yellow';
        system.assertEquals(7.5, testme.avrgCES);
        system.assertEquals('Yellow', testme.CES_Colour);
  }
    
  public static testMethod void testAvgCES4() {
        Account a = new Account(name='TestAcc',Reseller_Id__c=12345,Virtualisation_Id__c=1);
        insert a;
        Case c = new Case(subject='Test Case',Account=a,How_easy_was_it_to_get_the_help_you_need__c=NULL);
        Case c2 = new Case(subject='Test Case2',Account=a,How_easy_was_it_to_get_the_help_you_need__c=NULL);
        insert c;
        insert c2;
        ApexPages.StandardController sc4 = new ApexPages.standardController(c);
        avgCES testme = new avgCES(sc4);
        testme.avrgCES=0;
        testme.CES_Colour='Grey';
        system.assertEquals(0, testme.avrgCES);
        system.assertEquals('Grey', testme.CES_Colour);
  }
    

}


Im still fairly new to Apex and would appreciate any and all help with this.

Thanks in advance!
Hi everyone,
After I developed, and upload as managed package. but when i logged into business account on AppExchange, I found no way to list package from dev org.

Thank you!

 
Hello everyone,

I scan my code , and I received a Serious issue:

e.g : <apex:inputText value="{!ld.Name}" />

I have applied FLS :  as the guide here :  http://wiki.developerforce.com/page/Enforcing_CRUD_and_FLS

e.g : <apex:inputText value="{!ld.Name}"  rendered="{!$ObjectType.Lead.fields.Name.Updateable}"/>

but it not worked.

I scan my code on with Beta Rules (+CRUD/FLS), and I received a Serious issue:

Query Name - Dereferenced_Field
Severity
- Serious

Dereferenced_Field  what does it mean ?

Hello everyone,

I have a trigger change owner before insert a new lead record.

 

trigger trickOnLead on Lead (before insert) { 
   for (Lead ld : Trigger.new) {
         if(ld.testId__c != null ){
             ld.ownerid = ld.testId__c; 
         }
   }
}

 

 

-------------

I tested it through web-to-lead, and its successful.(on Monday, July 8th),

but today its not work anymore ?!

note that it only work for manual create a new record.

 

Thanks,

Manh

 

 

 

Hello everyone,

I've jumped from Java to Apex code, but I can not find a suitable IDE like Eclipse for Java, When I clicked "Ctrl + Space"

it does not show any suggestion for keywords or anotations like "implements ,  @RestResource"  ?

 

Thanks,

Manh

 

 

 

I scan my code on with Beta Rules (+CRUD/FLS), and I received a Serious issue:

Query Name - Dereferenced_Field
Severity
- Serious

Dereferenced_Field  what does it mean ?

Hi ,

  I am adding a workflow rule on Lead. When Appoinment_Created_date is not null then update Lead Status to SQL.

  Updating am doing through field update. But below forumla is not working Please suggest me how to fix.

 NOT(ISBLANK(Appointment_Created_Date__c)) 

  I even tried NOT(ISNULL(Appointment_Created_Date__c))


Thanks

Sudhir

Hello Developers,

What is the best envoirement of writing apex code?

Do you I have to download eclpise and to install Force.com IDE?

Thanks,

David

Hey all - I am an admin new to learning code and need a little help.  I have a custom object called Counties.  In this custom object are records that contain every zipcode, city, county, and state in the U.S.. 

I also have a "County" field on my contact object.

I would like to auto update the County field on my contact object automatically based on its zipcode.  I want to accomplish this by having the contact zipcode lookup the matching zipcode in the counties object and then return the actual County value onto the contact object.

Make sense?

I'm pretty sure I need an apex trigger for this but I haven't learned how to make these yet - can anyone give me some help?  Here are some screen shots of both my contact object and my counties custom object:

User-added image



User-added image
My first attempt at coding and just can't make it work.  All I need is to pull records for a particular day, from a preload table and update the volume counts.  When I click on save or enter the date it creates a new record.  How  can I fix this?  

Here is the code:

public class RescueCountExtension {

    private final Rescue_count__c acct;

    public RescueCountExtension(ApexPages.StandardController stdController) {
        this.acct = (Rescue_count__c)stdController.getRecord();
 
   }
public Date SelectedDate {get;set;}

List<Rescue_Count__c> theDaysRecords;

Public List<Rescue_Count__c> getTheDaysRecords(){
   if(theDaysRecords == null){
      theDaysRecords = [SELECT Donor__c, Rescue_Date__c, BR__C, BU__c, BA__c, TA__c, BA_Bulk__C, TA_Bulk__C,Produce__c, Meat_Deli__c, Shelf_Stable__c, Non_Food__c from Rescue_count__c Order by Donor__c ];
}
return theDaysRecords;   
       
    }
}


//THE PAGE:
<apex:page standardController="Rescue_Count__c" extensions="RescueCountExtension" sidebar="false">

  
<apex:sectionheader title="Mass Edit Rescue Counts" />
<apex:form >

<apex:pageBlock title="Rescue Counts" rendered="true" mode="edit" >
<apex:pageMessages />

Note: All modifications made on the page will be lost if Return button is clicked without clicking the Save button first.

<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>     

<apex:pageBlockSection title="Records to Update"
collapsible="false">
<apex:outputLabel value="Select Date"/>

<apex:inputText value="{!SelectedDate}" size="10" id="queryDate" onfocus="DatePicker.pickDate(false, this, false);" />
  <apex:actionSupport event="onchange" rerender="thetable"/>

</apex:pageBlockSection>

<apex:pageBlockTable value="{!theDaysRecords}" var="a" id="thetable">
<apex:column headerValue="Donor">
<apex:outputField value="{!a.Donor__c}"/>
</apex:column>
<apex:column headerValue="Date">
<apex:outputField value="{!a.Rescue_Date__c}"/>
</apex:column>
<apex:column headerValue="BR">
<apex:inputField value="{!a.BR__c}"/>
</apex:column>
<apex:column headerValue="BU">
<apex:inputField value="{!a.BU__c}"/>
</apex:column>
<apex:column headerValue="BA">
<apex:inputField value="{!a.BA__c}"/>
</apex:column>
<apex:column headerValue="TA">
<apex:inputField value="{!a.TA__c}"/>
</apex:column>
<apex:column headerValue="BA_Bulk">
<apex:inputField value="{!a.BA_Bulk__c}"/>
</apex:column>
<apex:column headerValue="TA_Bulk">
<apex:inputField value="{!a.TA_Bulk__c}"/>
</apex:column>
<apex:column headerValue="Produce">
<apex:inputField value="{!a.Produce__c}"/>
</apex:column>
<apex:column headerValue="Meat/Deli">
<apex:inputField value="{!a.Meat_Deli__c}"/>
</apex:column>
<apex:column headerValue="Shelf Stable">
<apex:inputField value="{!a.Shelf_Stable__c}"/>
</apex:column>
<apex:column headerValue="Non_Food">
<apex:inputField value="{!a.Non_Food__c}"/>
</apex:column>
</apex:pageBlockTable>

</apex:pageBlock>
</apex:form>
</apex:page>
I am trying to get the API Names of a field of a certain object.

For example, I have a field named Testing with an API name of Testing__c.

However when I use 
Set<String> fieldExistingCompare = new Set<String>();

Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Map<String, Schema.SObjectField> fieldMap = schemaMap.get('Request__c').getDescribe().fields.getMap();
Then getting the values via loop like this...
for (String fieldAPINameIN: fieldMap.keySet())
{
              fieldExistingCompare.add(fieldAPINameIN);
}
I get testing__c instead. I need to get the actual API Name of the field with the proper capitalizations.

How do I achieve this? Some people have done it yet I still don't get it.

Your help is deeply appreciated.

Thank you!


When trying to create a new Force.com project , I am getting a weird error :

Invalid Api version specified on URL

I have tried using Eclipse - Juno and Kepler. I suspect issue might be because of the IDE version 31.0 
Have followed every single step provided in the below link
https://developer.salesforce.com/page/Force.com_IDE_Installation



Hi,
I would like to get the Title field from the cotact associated with the task.
Can this be achieved by using a formula field or some other easier way?
I can only get the whoid not the related fields of contact object.

So trigger on task object is the only option that I could think of
I would like to explore the options before going ahead with the trigger.Pl let me know if any?

Many thanks in advance.

I can't see system log. Can anybody know about this?
Hi,

i have one requirement regarding avoid duplicates of products in salesforce.i.e,any new Product with same info like Name,Productcode matches with existing product record,the old one can be deleted and new one will be inserted.

can any one suggest me how to achieve this....



Hello everyone,

I need a hand getting 100% code coverage for one of my Apex Classes

The Apex Class:
public class avgCES{

    private final Case cas;

    public double avrgCES{public get; public set;}
    public string CES_Colour{public get; public set;}
    public double count{public get; public set;}

    public avgCES(ApexPages.StandardController controller) {

    this.cas = (Case)Controller.getRecord();
    

if(cas.account.id!=NULL){
    
    List <case> allCase=[Select How_easy_was_it_to_get_the_help_you_need__c from case where accountid=:cas.account.id and How_easy_was_it_to_get_the_help_you_need__c!=NULL];

    double d=0.0;
    integer count=0;
    if(allCase.size()>0){
    for(case c: allCase)
    {
     d+=c.How_easy_was_it_to_get_the_help_you_need__c;
     count++;
    }
    }
    
    
    if(count>0)
    {
        avrgCES=d/count;
    }
    else
    {
        avrgCES=0;
        CES_Colour='Grey';
    }
    
    if(avrgCES<6)
    {
        CES_Colour='Red';
    }
    else if(avrgCES>=6 && avrgCES <=8 )
    {
        CES_Colour='Yellow';
    }
    else
    {
        CES_Colour='Green';
    }
}
}
}

The Test Class
@isTest
public class avgCES_test{
    public static testMethod void testAvgCES() {
        Account a = new Account(name='TestAcc',Reseller_Id__c=12345,Virtualisation_Id__c=1);
        insert a;
        Case c = new Case(subject='Test Case',Account=a,How_easy_was_it_to_get_the_help_you_need__c=6);
        Case c2 = new Case(subject='Test Case2',Account=a,How_easy_was_it_to_get_the_help_you_need__c=5);
        insert c;
        insert c2;
        ApexPages.StandardController sc = new ApexPages.standardController(c);
        avgCES testme = new avgCES(sc);
        testme.avrgCES=5.5;
        testme.CES_Colour='Red';
        
        system.assertEquals(5.5, testme.avrgCES);
        system.assertEquals('Red', testme.CES_Colour);
  }
    
    public static testMethod void testAvgCES2() {
        Account a = new Account(name='TestAcc',Reseller_Id__c=12345,Virtualisation_Id__c=1);
        insert a;
        Case c = new Case(subject='Test Case',Account=a,How_easy_was_it_to_get_the_help_you_need__c=10);
        Case c2 = new Case(subject='Test Case2',Account=a,How_easy_was_it_to_get_the_help_you_need__c=8);
        insert c;
        insert c2;
        ApexPages.StandardController sc2 = new ApexPages.standardController(c);
        avgCES testme = new avgCES(sc2);
        testme.avrgCES=9;
        
        system.assertEquals(9, testme.avrgCES);
        system.assertEquals('Green', testme.CES_Colour);
  }
    
  public static testMethod void testAvgCES3() {
        Account a = new Account(name='TestAcc',Reseller_Id__c=12345,Virtualisation_Id__c=1);
        insert a;
        Case c = new Case(subject='Test Case',Account=a,How_easy_was_it_to_get_the_help_you_need__c=7);
        Case c2 = new Case(subject='Test Case2',Account=a,How_easy_was_it_to_get_the_help_you_need__c=8);
        insert c;
        insert c2;
        ApexPages.StandardController sc3 = new ApexPages.standardController(c);
        avgCES testme = new avgCES(sc3);
        testme.avrgCES=7.5;
    
        testme.CES_Colour='Yellow';
        system.assertEquals(7.5, testme.avrgCES);
        system.assertEquals('Yellow', testme.CES_Colour);
  }
    
  public static testMethod void testAvgCES4() {
        Account a = new Account(name='TestAcc',Reseller_Id__c=12345,Virtualisation_Id__c=1);
        insert a;
        Case c = new Case(subject='Test Case',Account=a,How_easy_was_it_to_get_the_help_you_need__c=NULL);
        Case c2 = new Case(subject='Test Case2',Account=a,How_easy_was_it_to_get_the_help_you_need__c=NULL);
        insert c;
        insert c2;
        ApexPages.StandardController sc4 = new ApexPages.standardController(c);
        avgCES testme = new avgCES(sc4);
        testme.avrgCES=0;
        testme.CES_Colour='Grey';
        system.assertEquals(0, testme.avrgCES);
        system.assertEquals('Grey', testme.CES_Colour);
  }
    

}


Im still fairly new to Apex and would appreciate any and all help with this.

Thanks in advance!
I have a custom command button in a visualforce page that when clicked performs an action. For this action, I refresh a page block that has fields that are required. However, I do not want them to be required at this point, so I use immediate="true", which is partially working. The action isn't actually being prevented, but the field required message is still displayed (screenshot attached). Can anyone explain why this might be happening? Thank you!!

<apex:column headerValue="Add Test">
                    <apex:actionStatus id="addStatus" >
                        <apex:facet name="stop" >
                            <apex:commandButton value="Select" action="{!addToQuoteLineItemWrappers}" reRender="selected,errors" immediate="true" image="{!$Resource.GreenPlus}" status="addStatus">
                                <apex:param value="{!product.Id}" assignTo="{!toSelectId}" name="toSelectId"/>
                            </apex:commandButton>
                        </apex:facet>
                        <apex:facet name="start">
                            <apex:commandButton value="Adding - See Below" disabled="true" status="addStatus" />
                        </apex:facet>
                    </apex:actionStatus>
 </apex:column>
User-added image

Hello everyone,

I scan my code , and I received a Serious issue:

e.g : <apex:inputText value="{!ld.Name}" />

I have applied FLS :  as the guide here :  http://wiki.developerforce.com/page/Enforcing_CRUD_and_FLS

e.g : <apex:inputText value="{!ld.Name}"  rendered="{!$ObjectType.Lead.fields.Name.Updateable}"/>

but it not worked.

I have couple of pages in an application
Says as page1 ,page2,page3,page4,page5.All the five pages are having same content as footer and header??
when i add some sentences on page 1 ,it should appear in all the pages .How can we achieve this??

Hello everyone,

I have a trigger change owner before insert a new lead record.

 

trigger trickOnLead on Lead (before insert) { 
   for (Lead ld : Trigger.new) {
         if(ld.testId__c != null ){
             ld.ownerid = ld.testId__c; 
         }
   }
}

 

 

-------------

I tested it through web-to-lead, and its successful.(on Monday, July 8th),

but today its not work anymore ?!

note that it only work for manual create a new record.

 

Thanks,

Manh

 

 

 

Hello everyone,

I've jumped from Java to Apex code, but I can not find a suitable IDE like Eclipse for Java, When I clicked "Ctrl + Space"

it does not show any suggestion for keywords or anotations like "implements ,  @RestResource"  ?

 

Thanks,

Manh

 

 

 

Hello All,

 

My Name is Raghav Sharma. I am working in a software company in India. Currently I am working on the project where I need to use saleforce api and show in the outlook plug in and google contextual gadget. The outlook plug in is almost done but I got no information regarding google contextual gadget with sales force API. I am able to develop the google contextual gadget but I don't know how to show data of sale force into the contextual gadget. First I think there is no way to do this but I see zoha project already implement this functionality. So If any one have information please let me know I am very thankful to you guys :)

 

Regards,

Raghav Sharma

I am trying to get the API Names of a field of a certain object.

For example, I have a field named Testing with an API name of Testing__c.

However when I use 
Set<String> fieldExistingCompare = new Set<String>();

Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Map<String, Schema.SObjectField> fieldMap = schemaMap.get('Request__c').getDescribe().fields.getMap();
Then getting the values via loop like this...
for (String fieldAPINameIN: fieldMap.keySet())
{
              fieldExistingCompare.add(fieldAPINameIN);
}
I get testing__c instead. I need to get the actual API Name of the field with the proper capitalizations.

How do I achieve this? Some people have done it yet I still don't get it.

Your help is deeply appreciated.

Thank you!