• FearNone
  • SMARTIE
  • 594 Points
  • Member since 2016


  • Chatter
    Feed
  • 17
    Best Answers
  • 0
    Likes Received
  • 14
    Likes Given
  • 1
    Questions
  • 113
    Replies
I have a lookup field and a extenstion to convert the lookup as a select list. Debug log is showing options, but the VF page is not... Any ideas of why the select options aren't populating? 
 
public class BIWorkOrder {
    public Work_Order__c wo {get; set;}  
    public list<Deployment_Cycle__c> Deployments {get;set;}
    public List<SelectOption> options {get; set;}
    public BiWorkOrder(ApexPages.StandardController stdcontroller)
    {
        this.wo = (Work_Order__c)stdcontroller.getRecord();
        getItems();

    }
     public List<SelectOption> getItems() {
        Deployments = [SELECT ID, Deployment_Date__c from Deployment_cycle__c where Deployment_Date__c > :system.Today() and Active__c = true order By Deployment_date__c ASC];
        list<selectOption> options = new List<selectOption>(); 
        for(Deployment_Cycle__c d :deployments)
        {
           string newDate = d.Deployment_date__c.month() + '/' + d.deployment_date__c.day() + '/' + d.deployment_date__c.year();
           options.add(new selectOption (d.id, newDate));
        }
         system.debug(options);
 return options;
         
    }
}
 
<apex:pageBlockSection title="BI Fields" columns="2">
                <apex:inputField value="{!Work_Order__c.Resource__c}" required="false"/>
                <apex:selectList value="{!Work_Order__c.Deployment_Cycle__c}" > ---> Lookup field
                <apex:selectOptions value="{!Options}"></apex:selectOptions>  ---> Options 
                </apex:selectList>
                <apex:inputField value="{!Work_Order__c.Due_Date__c}" required="false"/>
                <apex:inputField value="{!Work_Order__c.Notes__c}" required="false"/>
                <apex:inputField value="{!Work_Order__c.Date_Complete__c}" required="false"/>
                         
            </apex:pageBlockSection>
Debug:

16:48:39:015 USER_DEBUG [20]|DEBUG|(System.SelectOption[value="aBv1b00000000EiCAI", label="2/3/2017", disabled="false"])
 
hi there,

Is there another way to show time for Created Date,
without using custom field.

Regards,
LinThaw.
Hi
I am trying to understand how to compare old values and new values for sobject.
I have a opportunity custom field , type=check box, which is checked only when stageName='Closed Won'.

when the custom field is checked the trigger further will do some business logic.

any help will ge greatly apprecitaed.

thanks


 
trigger Customer_After_Insert on APEX_Customer__c (after update)
{
(*)List InvoiceList = new List();
for (APEX_Customer__c objCustomer: Trigger.new)
{
if (objCustomer.APEX_Customer_Status__c == 'Active')
{
APEX_Invoice__c objInvoice = new APEX_Invoice__c();
(*)objInvoice.APEX_Status__c = 'Pending';
(*) InvoiceList.add(objInvoice);
}
}
}
Can SomeOne Explain me the code flow speciall the "(*)"->Points
 IF(  AND( YEAR(TODAY())-1 = YEAR(OrderDate__c), TODAY()-1 >= Date(year(Today()), month(OrderDate__c), day(OrderDate__c))),  OrderAmount__c, 0)

Thanks! Anne
Hi All,

I am new to writing apex in Eclipse IDE. I would like to know if i can get the method names for the class like in Dev console

eg: when i write System. in console ill get all the options 
i would like to know if we have that option in eclipse
I want to populate a parent field value in a chaild field for displaying in a standard visual force page. So, I thought I will create a formula field for the same, but one of my collegue said don't create formula field, create a text field and assign the text field value while creating the child record in trigger.

So, I just want to know, which approach is better and why?

NOTE: The parent child relationship is lookup relationship.
Hello, I have an Object with a list inside of of it. The two values I want to retrieve are 'Label' and 'Link.'  How do I get those values.  The error messages keep telling me I need an SObject.  The Object is not an SObject.  Looks something like this.

Link:[Label=FirstButton,Link=https://www.here.com],[Label=SecondButton,Link=https://www.there.com]
I want to get the value of 'Label' and 'Link' 
List<Object> OuterTable = new List<Object>();
OuterTable = response.LTable;
        for (Integer i=0;i<OuterTable.size();i++) { 
            System.debug('OK Until here' + OuterTable.get(i));   
//Don't know how to get the rest
}
Any help would be appreciated.

Thanks! 
 
went to finish up visualForce  trails/modules on dev org, noticed account name is blocked. already checked profile, heirarchy perm. sets roles cannot seem to solve issue have gone through basic object field level security as well.

Thanks any advice appreciated.

error msg  -> 
core.apexpages.exceptions.ApexPagesHandledException: Object type not accessible. Please check permissions and make sure the object is not in development mode: Name, Phone FROM Account ORDER BY Name ASC LIMIT 10000 ^ ERROR at Row:1:Column:56 encrypted field 'Name' cannot be ordered in a query call. Original queryString was: 'SELECT Id, Industry, Name, Phone FROM Account ORDER BY Name ASC LIMIT 10000' 
Previous employee wrote Trigger/Class and it's causing an issue during lead conversion (See screenshot). Any help on how to fix would be greatly appreciated!
Error Message

Here is the code of the Class:
 
public class Kash_Task {
  public static void processUpdate(Task[] tasks_new, Task[] tasks_old) {        
      
        // update related LEAD for this task if applicable
        String LeadPREFIX = Schema.SObjectType.Lead.getKeyPrefix();
        
        if (tasks_new != null) {
            for(integer i=0; i<tasks_new.size(); i++) {
                Task t = tasks_new[i];
                if (t.WhoId!=null && ((String)t.WhoId).startsWith(LeadPREFIX)) {
                   Kash_Task.updateLead_NextAction(t.WhoId);
                }            
            }
        }
        
        if (tasks_old != null) {
            for(integer i=0; i<tasks_old.size(); i++) {
                Task t = tasks_old[i];
                if (t.WhoId!=null && ((String)t.WhoId).startsWith(LeadPREFIX)) {
                   Kash_Task.updateLead_NextAction(t.WhoId);
                }            
            }
        }
    }
    
    public static void  updateLead_NextAction(ID LeadId) {
        Lead l = [SELECT Id, Status, OwnerId FROM Lead WHERE Id=:LeadId];        
        
        // set next open task
        List<Task> nextTaskList = [SELECT Id, ActivityDate, Subject From Task Where (WhoId=:LeadId AND isDeleted=false AND Status='Open') ORDER BY ActivityDate ASC LIMIT 1];
        if (!nextTaskList.isEmpty()) {
            Task nextTask = nextTaskList[0];
          l.Next_Action__c = nextTask.Subject;
          l.Next_Action_Date__c  = nextTask.ActivityDate;
        }
        else {
            l.Next_Action__c = null;
          l.Next_Action_Date__c  = null;
        }
        
        // set last completed task
        List<Task> lastTaskList = [SELECT Id, ActivityDate, Subject From Task Where (WhoId=:LeadId AND isDeleted=false AND Status='Completed') ORDER BY ActivityDate DESC LIMIT 1];
        if (!lastTaskList.isEmpty()) {
            Task lastTask = lastTaskList[0];
          l.Last_Action__c = lastTask.Subject;
          l.Last_Action_Date__c  = lastTask.ActivityDate;
        }
        else {
            l.Last_Action__c = null;
          l.Last_Action_Date__c  = null;
        }

        update l;
    }
}

Here is the Trigger:
 
trigger Kash_Task_Trigger on Task (after insert, after update, after delete, after undelete) {
    if (trigger.isInsert || trigger.isUndelete) {
        Kash_Task.processUpdate(trigger.new, null);        
    }
    else if (trigger.isUpdate) {
        Kash_Task.processUpdate(trigger.new, trigger.old);
    }
    else if (trigger.isDelete) {
        Kash_Task.processUpdate(null, trigger.old);
    }


 
I have read some posts on the forum, which use this as a demonstration of how to create good code coverage. http://amitsalesforce.blogspot.mx/2015/06/best-practice-for-test-classes-sample.html


I am using the Force.com Developer console, and when running tests the code coverage goes up to 40% or less, sometimes changing by 2%. The code not covered, according to the console has the following format:


 
if(Database.countQuery('SELECT count() FROM User WHERE User.Id = \''+ Object.variable+'\'') > 0)
             usr.add(Database.query('SELECT Id,Email FROM User WHERE User.Id = \''+ Object.variable +'\''));
Now how do have to code this from the test perspective? I have created SObjects accordingly in the test class, but even if I do, the console does not increase the code coverage for the class intended to be set in production.


 
Hi,

Can someone please help me in covering the test class for the below code and I have tried a lot to cover it to 100% but I am getting 81% 

public with sharing class COCaseComment
{
    public String test2 {get;set;}
    public String test1 {get;set;}
    public string status {get;set;}

    public void save() {
        Id caseId = ApexPages.currentPage().getParameters().get('caseid');
        SavePoint sp = Database.setSavePoint();
        status = 'unsaved';
        try {
            Case c = [SELECT Id,status,xyz1__c, xyz2__c FROM Case WHERE Id = :caseId FOR UPDATE];
            c.Status = 'Closed';
            insert new casecomment(ParentId = caseId, commentbody = 'Question:'+ '\n' + test1 + '\n' + 'solution :'+ '\n'+ test2 , IsPublished = true);
            update c;
            status = 'saved';
        } catch(Exception e) {
            Apexpages.addMessage(new ApexPages.message(Apexpages.Severity.Error, e.getMessage()));
            Database.rollback(sp);
        }
    }
}

Test class 

@isTest
public class TestCustomerOperationsCaseComment
{
    @isTest public static void withcaseid() {
        case c = new
        case (status = 'New', Origin = 'Phone', xyz1__c= 'AMR', xyz2__c = 'Charting Issues');
        insert c;
        case ca = [select id, status, xyz1__c ,xyz2__c from case where status = 'New'];
        Test.setCurrentPage(page.COcaseComment);
        COCaseComment cs = new COCaseComment();
        cs.Test1 = ('test1');
        cs.Test2 = ('test2');
        apexpages.currentPage().getparameters().put('caseid', ca.id);
        if (ca.id != null) {
            cs.save();
        }
        casecomment cm = [select commentbody, isPublished from casecomment where parentid =: ca.Id];
        string str = 'Question:'+ '\n' + test1 + '\n' + 'solution:'+ '\n'+ test2 ;
        system.assertEquals(str, cm.CommentBody);
        system.assert(true, cm.ispublished);
        case g = [select Status from case where ID = :ca.Id ];
        system.assertEquals('Closed', g.status);
    }


    @isTest static void caseWithoutproduct() 
   {
      
            case c = new
            case (status = 'New', Origin = 'Phone', xyz2__c = 'Charting Issues');
            insert c;
            pagereference pr = page.COcaseComment;
            pr.getParameters().put('caseid', c.Id);
            test.setCurrentPage(pr);
            COCaseComment cc = new COCaseComment();
            cc.save();
          System.assert(ApexPages.hasMessages(ApexPages.SEVERITY.Error));
         System.assertEquals('unsaved', cc.status);
    
    }
}



 
  • July 28, 2016
  • Like
  • 1
I am having a VF page and class and test class.I am getting 43% code coverage.How can i increae it?
Below is my aoex class which gets value from user on VF page and creates account.

When i debug the test classs,i am not getting account.name value even though i gave a.name='testaccount' in my test class.
So i am able to cover those lines of code.Please help me what am i missing.
 
public class new_classforpage {
    Public customobjectt__c pr{get;set;}
    
    Public string accountname{get;set;}
    public string contactname{get;set;}
    public string contactemail{get;set;}
   
    public Account account {get;set;}


    public new_classforpage(ApexPages.StandardController sc) {
    pr= (object__c )sc.getRecord();
    account=new account();
    }
    
    Public pagereference save(){
     upsert pr;

    if(accountname!= '' && accountname!= null){
      
        account.name=accountname;
       
        upsert account;
        
        contact c=new contact();
        c.accountid=account.id;
        c.lastName=contactname;
        c.Email=contactemail;;
        insert c;
            
        pr.account_Name__c=account.id;
        update Pr;
    }
    
   return new PageReference('/'+pr.Id+'/e?retURL=%2F'+pr.Id);   
    }
}

and this is my test class:
 
@istest
Public class test_classforpage{
    static testMethod void test(){
        test.startTest();        
        PageReference pref = Page.mypage;
        Test.setCurrentPage(pref);
        
        
        Account a =new account();

        a.name='accountname';
       
        if(a.name!= '' && a.name!= null){

        upsert a;
        
        contact c=new contact();
        c.lastname='test contact';
        c.accountid=a.id;
        c.email='testemail@gmail.com';
        insert c;
        
        Purchase_request__c pr =new Purchase_request__c();
        pr.account_Name__c=a.id;
        
        insert pr;
        
        update pr;

        // Instantiate standard Controller
        ApexPages.StandardController sc = new ApexPages.StandardController(pr);

        // Instantiate controller extension
        myclass  mc = new myclass (sc);
                
        mc.save();
           test.stopTest();
}
     }
}


 
I have a formula field that calculates the value of 2 date/time fields when subtracted 
TEXT(FLOOR( (Paused_End__c - Paused_Start__c) * 24 )) & " Hours " &
TEXT(ROUND((( (Paused_End__c - Paused_Start__c) * 24 )* 60),0)) & " Minute"

and its result is "23  Hours 20 Minute"

How can i add the days as well, what function formula will I use so it will show "2 Days 23 Hours 20 Minute"

Hello,

I need help on some calculation for my trigger.

Basically, what I would like to do is to get value like if the Result is 16, then this will round to 30, if it's 24 then it will still be 30, if the value is 32 then it will be 45.

What I did was :

integer x = 32;
double y = doubleValueOf(x - math.mod(x)) + 15;

But this doesn't seem to be consistent. Can I have some other sure approach to achieve this?


Thanks

Hi,

Can anyone suggest me a better formula? This is working fine, however I wanted to see if I get a better formula as it is lengthy one.

CASE( MS_Score__c ,
"0",Profile_Score__c +MS_Score__c,
"1",Profile_Score__c +MS_Score__c,
"2",Profile_Score__c +MS_Score__c,
"3",Profile_Score__c +MS_Score__c,
"4",Profile_Score__c +MS_Score__c,
"A0",Profile_Score__c +RIGHT(MS_Score__c,1),
"A1",Profile_Score__c +RIGHT(MS_Score__c,1),
"A2",Profile_Score__c +RIGHT(MS_Score__c,1),
"A3",Profile_Score__c +RIGHT(MS_Score__c,1),
"A4",Profile_Score__c +RIGHT(MS_Score__c,1),
"B1",Profile_Score__c +RIGHT(MS_Score__c,1),
"B2",Profile_Score__c +RIGHT(MS_Score__c,1),
"B3",Profile_Score__c +RIGHT(MS_Score__c,1),
"B4",Profile_Score__c +RIGHT(MS_Score__c,1),
"C0",Profile_Score__c +RIGHT(MS_Score__c,1),
"C1",Profile_Score__c +RIGHT(MS_Score__c,1),
"C2",Profile_Score__c +RIGHT(MS_Score__c,1),
"C3",Profile_Score__c +RIGHT(MS_Score__c,1),
"C4",Profile_Score__c +RIGHT(MS_Score__c,1),
"D1",Profile_Score__c +RIGHT(MS_Score__c,1),
"D2",Profile_Score__c +RIGHT(MS_Score__c,1),
"D3",Profile_Score__c +RIGHT(MS_Score__c,1),
"D4",Profile_Score__c +RIGHT(MS_Score__c,1),
"E0",Profile_Score__c +RIGHT(MS_Score__c,1),
"E1",Profile_Score__c +RIGHT(MS_Score__c,1),
"E2",Profile_Score__c +RIGHT(MS_Score__c,1),
"E3",Profile_Score__c +RIGHT(MS_Score__c,1),
"E4",Profile_Score__c +RIGHT(MS_Score__c,1),
"U0",Profile_Score__c +RIGHT(MS_Score__c,1),
"U1",Profile_Score__c +RIGHT(MS_Score__c,1),
"U2",Profile_Score__c +RIGHT(MS_Score__c,1),
"U3",Profile_Score__c +RIGHT(MS_Score__c,1),
"U4",Profile_Score__c +RIGHT(MS_Score__c,1),
""
)
Regards,
Ajay
my account is displayed when searched Salesforce verification but no certificate is shown when I clicked the "View Certifications" button.
only "No Active Certification Credentials Found" message is displayed.
I followed the instruction in the link below to make my certificate public. Did I miss something? 

instruction 
http://certification.force.com/pkb/articles/Public_KB/Verification-Opt-in-Instructions 

Thank you in advance for your help.
how do I open a  ticket to contact sales support? I start here: https://help.salesforce.com/home > Technical Support > I click Go > https://help.salesforce.com/support > I click on Contact US > Then it asks me to login @ https://login.salesforce.com/?startURL=https%3A%2F%2Flogin.salesforce.com%2Fservices%2Fauth%2Fsso%2F00D30000000XsfGEAS%2FHTAuthProvider%3FstartURL%3D%2Fapex%2FHelp_Home%26site%3Dhttps%3A%2F%2Fhelp.salesforce.com and it keeps on looping. What do I do or go to actually log a ticket?

Hi developer community,

I am using node.js and the JSforce library.  I am trying to build a report using a few rules to identify the last valid activity on an account.  My SOQL query looks like this:
SELECT Id,
(SELECT OwnerId, ActivityDate, Status, ActivityType, ActivitySubtype, Subject, LastModifiedDate
FROM ActivityHistories
WHERE OwnerId IN (<list of ids>)
AND ActivityDate > <earliest-date>
AND ActivityDate < <latest-date>
ORDER BY ActivityDate desc)
FROM Account

This query sometimes runs to completion, but often terminates with the following error:
{ [Error: socket hang up] code: 'ECONNRESET' }

I have searched around and the best information I get seems to indicate that "this just happens sometimes".  I'm wondering if anyone has any more specific advice on troubleshooting or solving this problem.

A little experimentation seems to indicate that the query may be too complex (though again, it's odd that it only fails some (most) of the time).  This conclusion comes from the fact that simplifying the query, so that I simply get ALL the history for each account, seems to fail less (so far, it's succeeded every time, knock on wood).  This gives me a possible workaround, though I end up getting back a LOT more data and doing a lot more processing on the client than if I were to just get the subset I would get in the original SOQL shown above.  Plus, I would think that (aside form a possible longer "query optimization" phase, the more refined query would put less burden on the salesforce servers.

So long story short, I'd love to find a way to be able to process the above query in a reliable, robust way.

Any ideas, suggestions, etc would be very welcome!

Hi,
I am trying to write a validation rule against an encrypted field and getting the error:  Error: You referenced an unsupported field type called "Text (Encrypted)" using the following field: Password__c.  

The forumla I am using is:  IF(ISBLANK(Password__c),0,1).  What am I missing?
 
Hi all, I want the following post to be deleted which I created with a user which does not exists any more. I dropped an email to salesforce helpdesk but no help from the. It would be great if some one can help me with it.

Link for the post to be deleted:
https://developer.salesforce.com/forums/?id=906F0000000ArYrIAK
Dear All,
Can anyone plz suggest , where i went wrong in creating the below formula, as per me formula is correct, and its working on some values, but not working on others. I couldn't ablle to identify where exactly i went wrong. thnx for your support.

Formula Creation Criteria :

User-added image

The formula i created for this ,
 
AND( 
NOT(ISBLANK(Thai_Identification_Number__c)), 
VALUE(RIGHT(Thai_Identification_Number__c,1)) <> 
( 
11- 
( 
IF( 
MOD( 
ROUND( 
( 
VALUE(MID( Thai_Identification_Number__c ,1,1))*13 + 
VALUE(MID( Thai_Identification_Number__c ,2,1))*12 + 
VALUE(MID( Thai_Identification_Number__c ,3,1))*11 + 
VALUE(MID( Thai_Identification_Number__c ,4,1))*10 + 
VALUE(MID( Thai_Identification_Number__c ,5,1))*9 + 
VALUE(MID( Thai_Identification_Number__c ,6,1))*8 + 
VALUE(MID( Thai_Identification_Number__c ,7,1))*7 + 
VALUE(MID( Thai_Identification_Number__c ,8,1))*6 + 
VALUE(MID( Thai_Identification_Number__c ,9,1))*5 + 
VALUE(MID( Thai_Identification_Number__c ,10,1))*4 + 
VALUE(MID( Thai_Identification_Number__c ,11,1))*3 + 
VALUE(MID( Thai_Identification_Number__c ,12,1))*2 
) /11,1 )*10,10 
)=0, 
10, 
MOD( 
ROUND( 
( 
VALUE(MID( Thai_Identification_Number__c ,1,1))*13 + 
VALUE(MID( Thai_Identification_Number__c ,2,1))*12 + 
VALUE(MID( Thai_Identification_Number__c ,3,1))*11 + 
VALUE(MID( Thai_Identification_Number__c ,4,1))*10 + 
VALUE(MID( Thai_Identification_Number__c ,5,1))*9 + 
VALUE(MID( Thai_Identification_Number__c ,6,1))*8 + 
VALUE(MID( Thai_Identification_Number__c ,7,1))*7 + 
VALUE(MID( Thai_Identification_Number__c ,8,1))*6 + 
VALUE(MID( Thai_Identification_Number__c ,9,1))*5 + 
VALUE(MID( Thai_Identification_Number__c ,10,1))*4 + 
VALUE(MID( Thai_Identification_Number__c ,11,1))*3 + 
VALUE(MID( Thai_Identification_Number__c ,12,1))*2 
) /11,1 )*10,10 
) 
) 
) 
) 
)
While its working for some values, I ont know why its not working for the value mentioned in my screenshot " 1488708326392"
User-added image
 
Hi everyone, There have been some other posts on this exact same issue but none of those posted solutions have worked for me. I have a trigger that is firing twice when it should only be firing once. To solve this, I used checkRecursive (class pasted below). My trigger works fine now. However, my test class is not covering the section of my trigger which is isUpdate. This is due to the checkRecursive. 

Trigger:
 
trigger bsWarranty on QuoteLineItem (after insert,after update, after delete) {
     if(trigger.isinsert){
        for (QuoteLineItem QLI : Trigger.new) {
        for (Integer i = 0; i < QLI.Quantity; i++) {
            //if 0270-0200, add 0003-0129
        if ((QLI.PricebookEntryId == '01u61000003LhrX')) {
            
            QuoteLineItem newQLI = new QuoteLineItem();
            
            newQLI.Quantity        =   36;
            newQLI.QuoteId         =   QLI.QuoteId;
            newQLI.UnitPrice       =   0;
            newQLI.PricebookEntryId = '01u61000003LhqI';
                        
            insert newQLI;
        }}}
     for (QuoteLineItem QLI : Trigger.new) {
        for (Integer i = 0; i < QLI.Quantity; i++) {
           //if 0270-0404, add 0003-0374     
        if ((QLI.PricebookEntryId == '01u61000003LhpS')) {
            
            QuoteLineItem newQLI = new QuoteLineItem();
            
            newQLI.Quantity        =   36;
            newQLI.QuoteId         =   QLI.QuoteId;
            newQLI.UnitPrice       =   0;
            newQLI.PricebookEntryId = '01u61000003M03X';
                        
            insert newQLI;
        }}}
          for (QuoteLineItem QLI : Trigger.new) {
        for (Integer i = 0; i < QLI.Quantity; i++) {
            //if 0270-0870, add 0003-1179    
        if ((QLI.PricebookEntryId == '01u61000003LhpQ')) {
            
            QuoteLineItem newQLI = new QuoteLineItem();
            
            newQLI.Quantity        =   36;
            newQLI.QuoteId         =   QLI.QuoteId;
            newQLI.UnitPrice       =   0;
            newQLI.PricebookEntryId = '01u61000003LhqA';
                        
            insert newQLI;
        }}}
         for (QuoteLineItem QLI : Trigger.new) {
        for (Integer i = 0; i < QLI.Quantity; i++) {
            
        if ((QLI.PricebookEntryId == '01u61000003LhpR')|| //0270-0912 
           (QLI.PricebookEntryId == '01u61000003LhpX') || //0270-0878
           (QLI.PricebookEntryId == '01u61000003Lhpa') || //0270-0747
           (QLI.PricebookEntryId == '01u61000003Lhpb')) { //0270-0749
            //if above, add 0003-0878
            QuoteLineItem newQLI = new QuoteLineItem();
            system.debug(QLI.Quantity);
            newQLI.Quantity        =   36;
            newQLI.QuoteId         =   QLI.QuoteId;
            newQLI.UnitPrice       =   0;
            newQLI.PricebookEntryId = '01u61000003Lhpn';
                        
            insert newQLI;
        }}}
         for (QuoteLineItem QLI : Trigger.new) {
        for (Integer i = 0; i < QLI.Quantity; i++) {
            
        if ((QLI.PricebookEntryId == '01u61000003LhpT')|| //0270-0860
           (QLI.PricebookEntryId == '01u61000003LhpU') || //0270-0858
           (QLI.PricebookEntryId == '01u61000003LhpV') || //0270-0821
           (QLI.PricebookEntryId == '01u61000003LhpW') || //0270-0822
           (QLI.PricebookEntryId == '01u61000003LhpY') || //0270-0817
           (QLI.PricebookEntryId == '01u61000003LhpZ') || //0270-0818
           (QLI.PricebookEntryId == '01u61000003Lhpc') || //0270-0604
           (QLI.PricebookEntryId == '01u61000003Lhpe'))   //0270-0415
           //if above, add 0003-1085
        {
            
            QuoteLineItem newQLI = new QuoteLineItem();
            
            newQLI.Quantity        =   36;
            newQLI.QuoteId         =   QLI.QuoteId;
            newQLI.UnitPrice       =   0;
            newQLI.PricebookEntryId = '01u61000003Lhpy';
                        
            insert newQLI;
        }}}
          for (QuoteLineItem QLI : Trigger.new) {
        for (Integer i = 0; i < QLI.Quantity; i++) {
           //if 0270-0793 or 0270-0790 (not currently on contract), add 0003-0259     
        if ((QLI.PricebookEntryId == '01u61000003Lhpg')||
           (QLI.PricebookEntryId == '01u61000003Lhpd')) {
            
            QuoteLineItem newQLI = new QuoteLineItem();
            
            newQLI.Quantity        =   36;
            newQLI.QuoteId         =   QLI.QuoteId;
            newQLI.UnitPrice       =   0;
            newQLI.PricebookEntryId = '01u61000003LhqU';
                        
            insert newQLI;
        }}}}
        
        
        if (trigger.isupdate)   {
            
    if(RecursiveCheck.runOnce()){
               
        for (QuoteLineItem QLInew : Trigger.new){            
        Decimal QuantityNew = QLInew.Quantity;
            QuoteLineItem QLIold = Trigger.oldMap.get(QLInew.id);
        Decimal QuantityOld = QLIold.Quantity;    
        system.debug('@@@@@@@@@@'+QuantityOld);
            system.debug('@@@@@@@@@@'+QuantityNew);
            
        if (((QuantityNew != QuantityOld) &&
           (QLInew.Quote.Pricebook2.id == '01s61000003U9Id') &&
           ((QLInew.PricebookEntryId == '01u61000003LhrX') || // 0270-0200
            (QLInew.PricebookEntryId == '01u61000003LhpS') || // 0270-0404
            (QLInew.PricebookEntryId == '01u61000003LhpQ') || // 0270-0870
            (QLInew.PricebookEntryId == '01u61000003LhpR') || // 0270-0912
            (QLInew.PricebookEntryId == '01u61000003LhpX') || // 0270-0878
            (QLInew.PricebookEntryId == '01u61000003Lhpa') || // 0270-0747
            (QLInew.PricebookEntryId == '01u61000003Lhpb') || // 0270-0749
            (QLInew.PricebookEntryId == '01u61000003LhpT') || // 0270-0860
            (QLInew.PricebookEntryId == '01u61000003LhpU') || // 0270-0858
            (QLInew.PricebookEntryId == '01u61000003LhpV') || // 0270-0821
            (QLInew.PricebookEntryId == '01u61000003LhpW') || // 0270-0822
            (QLInew.PricebookEntryId == '01u61000003LhpY') || // 0270-0817
            (QLInew.PricebookEntryId == '01u61000003LhpZ') || // 0270-0818
            (QLInew.PricebookEntryId == '01u61000003Lhpc') || // 0270-0604
            (QLInew.PricebookEntryId == '01t61000001D7y6') || // 0270-0415
            (QLInew.PricebookEntryId == '01u61000003Lhpd') || // 0270-0793
            (QLInew.PricebookEntryId == '01u61000003Lhpg') //0270-0790
)))             
             {  

         system.debug(QuantityNew);
            system.debug(QuantityOld);
         
         List<QuotelineItem> zeroQLI = [SELECT id FROM QuoteLineItem WHERE UnitPrice = 0];
            delete zeroQLI;   
            }
                 
              for (QuoteLineItem QLI : Trigger.new) {
        for (Integer i = 0; i < QLI.Quantity; i++) {
            //if 0270-0200, add 0003-0129
        if ((QLI.PricebookEntryId == '01u61000003LhrX') && (QuantityNew != QuantityOld)) {
            
            QuoteLineItem newQLI = new QuoteLineItem();
            
            newQLI.Quantity        =   36;
            newQLI.QuoteId         =   QLI.QuoteId;
            newQLI.UnitPrice       =   0;
            newQLI.PricebookEntryId = '01u61000003LhqI';
                        
            insert newQLI;
        }}}
     for (QuoteLineItem QLI : Trigger.new) {
        for (Integer i = 0; i < QLI.Quantity; i++) {
           //if 0270-0404, add 0003-0374     
        if ((QLI.PricebookEntryId == '01u61000003LhpS') && (QuantityNew != QuantityOld)) {
            
            QuoteLineItem newQLI = new QuoteLineItem();
            
            newQLI.Quantity        =   36;
            newQLI.QuoteId         =   QLI.QuoteId;
            newQLI.UnitPrice       =   0;
            newQLI.PricebookEntryId = '01u61000003M03X';
                        
            insert newQLI;
        }}}
          for (QuoteLineItem QLI : Trigger.new) {
        for (Integer i = 0; i < QLI.Quantity; i++) {
            //if 0270-0870, add 0003-1179    
        if ((QLI.PricebookEntryId == '01u61000003LhpQ') && (QuantityNew != QuantityOld)) {
            
            QuoteLineItem newQLI = new QuoteLineItem();
            
            newQLI.Quantity        =   36;
            newQLI.QuoteId         =   QLI.QuoteId;
            newQLI.UnitPrice       =   0;
            newQLI.PricebookEntryId = '01u61000003LhqA';
                        
            insert newQLI;
        }}}
           for (QuoteLineItem QLI : Trigger.new) {
        for (Integer i = 0; i < QLI.Quantity; i++) {

        if ((QLI.PricebookEntryId == '01u61000003LhpR')|| //0270-0912
           (QLI.PricebookEntryId == '01u61000003LhpX') || //0270-0878
           (QLI.PricebookEntryId == '01u61000003Lhpa') || //0270-0747
           (QLI.PricebookEntryId == '01u61000003Lhpb')    //0270-0749
           && (QuantityNew != QuantityOld)) {
            //if above, add 0003-0878
            QuoteLineItem newQLI = new QuoteLineItem();
            system.debug(QuantityNew);
            system.debug(QuantityOld);
            newQLI.Quantity        =   36;
            newQLI.QuoteId         =   QLI.QuoteId;
            newQLI.UnitPrice       =   0;
            newQLI.PricebookEntryId = '01u61000003Lhpn';
                        
               insert newQLI;
        }}}
         for (QuoteLineItem QLI : Trigger.new) {
        for (Integer i = 0; i < QLI.Quantity; i++) {
            
        if ((QLI.PricebookEntryId == '01u61000003LhpT')|| //0270-0860
           (QLI.PricebookEntryId == '01u61000003LhpU') || //0270-0858
           (QLI.PricebookEntryId == '01u61000003LhpV') || //0270-0821
           (QLI.PricebookEntryId == '01u61000003LhpW') || //0270-0822
           (QLI.PricebookEntryId == '01u61000003LhpY') || //0270-0817
           (QLI.PricebookEntryId == '01u61000003LhpZ') || //0270-0818
           (QLI.PricebookEntryId == '01u61000003Lhpc') || //0270-0604
           (QLI.PricebookEntryId == '01t61000001D7y6')    //0270-0415
           && (QuantityNew != QuantityOld))
           //if above, add 0003-1085
        {
            
            QuoteLineItem newQLI = new QuoteLineItem();
            
            newQLI.Quantity        =   36;
            newQLI.QuoteId         =   QLI.QuoteId;
            newQLI.UnitPrice       =   0;
            newQLI.PricebookEntryId = '01u61000003Lhpy';
                        
            insert newQLI;
        }}}
          for (QuoteLineItem QLI : Trigger.new) {
        for (Integer i = 0; i < QLI.Quantity; i++) {
           //if 0270-0793 or 0270-0790 (not currently on contract), add 0003-0259     
        if ((QLI.PricebookEntryId == '01u61000003Lhpd')||
            (QLI.PricebookEntryId == '01u61000003Lhpg')
           && (QuantityNew != QuantityOld)) {
            
            QuoteLineItem newQLI = new QuoteLineItem();
            
            newQLI.Quantity        =   36;
            newQLI.QuoteId         =   QLI.QuoteId;
            newQLI.UnitPrice       =   0;
            newQLI.PricebookEntryId = '01u61000003LhqU';
                        
            insert newQLI;
           }}}}}}
        

        if(trigger.isdelete){
         for (QuoteLineItem QLInew : Trigger.old){            
           //  if (QLInew.Quote.Pricebook2.Name == 'Bon Secours (exp 1/5/2020)'){
        List<QuotelineItem> zeroQLI = [SELECT id FROM QuoteLineItem WHERE UnitPrice = 0];
        delete zeroQLI;
         }}}

Test Class:
 
@isTest(SeeAllData=true)
public class bsWarranty_Test {
    
    static testMethod void testBonSecoursWarranty(){
        
        Account acct = New Account();
        
        acct.Name                =   'Test Account';
        acct.PC_Territory__c     =   '1234'; 
        acct.CC_Territory__c     =   '1234';
        acct.Facility_Type__c    =   'Acute';
        acct.ShippingCountryCode =   'US';
        acct.ShippingStreet      =   '1234 Test Lane';
        acct.ShippingPostalCode  =   '12345';
        acct.ShippingStateCode   =   'WA';
         
        insert acct;
        
        Opportunity opp = New Opportunity();
        
        opp.Name = 'Test';
        opp.CloseDate = Date.today();
        opp.CurrencyIsoCode = 'USD';
        opp.AccountId = acct.id;
        opp.StageName = 'Qualified';
        opp.Business_Type__c = 'Patient care';
        opp.RecordTypeId = '012610000002W6nAAE';
        opp.Pricebook2Id = '01s61000003U9Id';
        
        insert opp;
        
        Quote quote = New Quote();
        quote.Name = 'Test';
        quote.ExpirationDate = date.today();
        quote.ShippingHandling = 0;
        quote.Ship_Date__c = date.today();
        quote.OpportunityId = opp.id;
        quote.Pricebook2Id = '01s61000003U9Id';
        insert quote;
        
        QuoteLineItem QLI = New QuoteLineItem();
        qli.QuoteId = Quote.Id;
        qli.PricebookEntryId = '01u61000003LhpS';
        qli.UnitPrice = 0;
        qli.Quantity = 1;
        insert QLI;
        
        QuoteLineItem QLI1 = New QuoteLineItem();
        qli1.QuoteId = Quote.Id;
        qli1.PricebookEntryId = '01u61000003LhrX';
        qli1.UnitPrice = 0;
        qli1.Quantity = 1;
        insert QLI1;
        
        QuoteLineItem QLI2 = New QuoteLineItem();
        qli2.QuoteId = Quote.Id;
        qli2.PricebookEntryId = '01u61000003LhpQ';
        qli2.UnitPrice = 0;
        qli2.Quantity = 1;
        insert QLI2;
        
        QuoteLineItem QLI3 = New QuoteLineItem();
        qli3.QuoteId = Quote.Id;
        qli3.PricebookEntryId = '01u61000003LhpR';
        qli3.UnitPrice = 0;
        qli3.Quantity = 1;
        insert QLI3;
        
        QuoteLineItem QLI4 = New QuoteLineItem();
        qli4.QuoteId = Quote.Id;
        qli4.PricebookEntryId = '01u61000003LhpT';
        qli4.UnitPrice = 0;
        qli4.Quantity = 1;
        insert QLI4; 
        
        QuoteLineItem QLI5 = New QuoteLineItem();
        qli5.QuoteId = Quote.Id;
        qli5.PricebookEntryId = '01u61000003Lhpg';
        qli5.UnitPrice = 0;
        qli5.Quantity = 1;
        insert QLI5;
        
        Quote quote1 = New Quote();
        quote1.Name = 'Test1';
        quote1.ExpirationDate = date.today();
        quote1.ShippingHandling = 0;
        quote1.Ship_Date__c = date.today();
        quote1.OpportunityId = opp.id;
        quote1.Pricebook2Id = '01s61000003U9Id';
        insert quote1;
        
        QuoteLineItem QLI6 = New QuoteLineItem();
        qli6.QuoteId = quote1.Id;
        qli6.PricebookEntryId = '01u61000003Lhpg';
        qli6.UnitPrice = 0;
        qli6.Quantity = 1;
        insert QLI6;
        
        QLI6.Quantity = 2;
        update QLI6;
        
        delete QLI6;
               
    }
}

RecursiveCheck class:
 
public Class RecursiveCheck{
    private static boolean run = true;
    public static boolean runOnce(){
    if(run){
     run=false;
     return true;
    }else{
        return run;
    }
    }
  }

If someone can point out how I need to change one of the three above blocks of code, that would be much appreciated. I'm getting good code coverage except under the IsUpdate clause due to the RecursiveCheck. 

Thank you!
I am using apex:selectList to display a multiselect list as a dropdown.  It works fine until i set multiselect to true then i get the error Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST,  when i try to save.  any suggestions?

<apex:selectList value="{!singleCon.DDMS__c}" styleClass="form-control" multiselect="true">
                                                                    <apex:selectOption itemValue="1" itemLabel="3"/>
                                                                    <apex:selectOption itemValue="2" itemLabel="2"/>
                                                                </apex:selectList>
I have a user that cannot get into our org because he forgot his answer to his security question.  I researched online and see I can use the developer console and set my own password for him to can access and then he can change his security question/answer.  I am not too familar with the developer console or APEX code.  I am trying to use the below, but get an error "Unknown error parsing query"

SELECT System.setPassword (userID='005G00000085EnF','NEWPASSWORD')

Can anyone identify what I have wrong?  Thanks

 
This is the line I'm trying to fix:
 
<apex:column headerValue="Status" headerClass="headerStyle" value="{!con.Status__c}" />

This doesn't work:
 
<apex:column headerValue="Status" headerClass="headerStyle" value="{!LEFT(con.Status__c,500)}" />

Thanks
I have an apex form  <apex:form id="productSelectionForm">

I want to dynamically set this to readonly  maybe on window.onload event or something .

Any suggestions would be appreciated
Hi Team,

I have a requirement where we just wanted to display the list of user's based on the permission we given.

Our input should be the permission name, then output should be the list of users those are having that permission.

Do we have any SOQL that supports this? or do we have any other workaround to display.

Thanks,
Anil



 
I have a lookup field and a extenstion to convert the lookup as a select list. Debug log is showing options, but the VF page is not... Any ideas of why the select options aren't populating? 
 
public class BIWorkOrder {
    public Work_Order__c wo {get; set;}  
    public list<Deployment_Cycle__c> Deployments {get;set;}
    public List<SelectOption> options {get; set;}
    public BiWorkOrder(ApexPages.StandardController stdcontroller)
    {
        this.wo = (Work_Order__c)stdcontroller.getRecord();
        getItems();

    }
     public List<SelectOption> getItems() {
        Deployments = [SELECT ID, Deployment_Date__c from Deployment_cycle__c where Deployment_Date__c > :system.Today() and Active__c = true order By Deployment_date__c ASC];
        list<selectOption> options = new List<selectOption>(); 
        for(Deployment_Cycle__c d :deployments)
        {
           string newDate = d.Deployment_date__c.month() + '/' + d.deployment_date__c.day() + '/' + d.deployment_date__c.year();
           options.add(new selectOption (d.id, newDate));
        }
         system.debug(options);
 return options;
         
    }
}
 
<apex:pageBlockSection title="BI Fields" columns="2">
                <apex:inputField value="{!Work_Order__c.Resource__c}" required="false"/>
                <apex:selectList value="{!Work_Order__c.Deployment_Cycle__c}" > ---> Lookup field
                <apex:selectOptions value="{!Options}"></apex:selectOptions>  ---> Options 
                </apex:selectList>
                <apex:inputField value="{!Work_Order__c.Due_Date__c}" required="false"/>
                <apex:inputField value="{!Work_Order__c.Notes__c}" required="false"/>
                <apex:inputField value="{!Work_Order__c.Date_Complete__c}" required="false"/>
                         
            </apex:pageBlockSection>
Debug:

16:48:39:015 USER_DEBUG [20]|DEBUG|(System.SelectOption[value="aBv1b00000000EiCAI", label="2/3/2017", disabled="false"])
 
 IF(  AND( YEAR(TODAY())-1 = YEAR(OrderDate__c), TODAY()-1 >= Date(year(Today()), month(OrderDate__c), day(OrderDate__c))),  OrderAmount__c, 0)

Thanks! Anne
Hi,

I am getting the below exception in my apex trigger. Can anyone suggest me how to resolve this issue?

FATAL_ERROR|System.LimitException: Query of LOB fields caused heap usage to exceed limit.

Thanks,
Vijay
I want to populate a parent field value in a chaild field for displaying in a standard visual force page. So, I thought I will create a formula field for the same, but one of my collegue said don't create formula field, create a text field and assign the text field value while creating the child record in trigger.

So, I just want to know, which approach is better and why?

NOTE: The parent child relationship is lookup relationship.
Hello, I have an Object with a list inside of of it. The two values I want to retrieve are 'Label' and 'Link.'  How do I get those values.  The error messages keep telling me I need an SObject.  The Object is not an SObject.  Looks something like this.

Link:[Label=FirstButton,Link=https://www.here.com],[Label=SecondButton,Link=https://www.there.com]
I want to get the value of 'Label' and 'Link' 
List<Object> OuterTable = new List<Object>();
OuterTable = response.LTable;
        for (Integer i=0;i<OuterTable.size();i++) { 
            System.debug('OK Until here' + OuterTable.get(i));   
//Don't know how to get the rest
}
Any help would be appreciated.

Thanks! 
 
went to finish up visualForce  trails/modules on dev org, noticed account name is blocked. already checked profile, heirarchy perm. sets roles cannot seem to solve issue have gone through basic object field level security as well.

Thanks any advice appreciated.

error msg  -> 
core.apexpages.exceptions.ApexPagesHandledException: Object type not accessible. Please check permissions and make sure the object is not in development mode: Name, Phone FROM Account ORDER BY Name ASC LIMIT 10000 ^ ERROR at Row:1:Column:56 encrypted field 'Name' cannot be ordered in a query call. Original queryString was: 'SELECT Id, Industry, Name, Phone FROM Account ORDER BY Name ASC LIMIT 10000' 
Previous employee wrote Trigger/Class and it's causing an issue during lead conversion (See screenshot). Any help on how to fix would be greatly appreciated!
Error Message

Here is the code of the Class:
 
public class Kash_Task {
  public static void processUpdate(Task[] tasks_new, Task[] tasks_old) {        
      
        // update related LEAD for this task if applicable
        String LeadPREFIX = Schema.SObjectType.Lead.getKeyPrefix();
        
        if (tasks_new != null) {
            for(integer i=0; i<tasks_new.size(); i++) {
                Task t = tasks_new[i];
                if (t.WhoId!=null && ((String)t.WhoId).startsWith(LeadPREFIX)) {
                   Kash_Task.updateLead_NextAction(t.WhoId);
                }            
            }
        }
        
        if (tasks_old != null) {
            for(integer i=0; i<tasks_old.size(); i++) {
                Task t = tasks_old[i];
                if (t.WhoId!=null && ((String)t.WhoId).startsWith(LeadPREFIX)) {
                   Kash_Task.updateLead_NextAction(t.WhoId);
                }            
            }
        }
    }
    
    public static void  updateLead_NextAction(ID LeadId) {
        Lead l = [SELECT Id, Status, OwnerId FROM Lead WHERE Id=:LeadId];        
        
        // set next open task
        List<Task> nextTaskList = [SELECT Id, ActivityDate, Subject From Task Where (WhoId=:LeadId AND isDeleted=false AND Status='Open') ORDER BY ActivityDate ASC LIMIT 1];
        if (!nextTaskList.isEmpty()) {
            Task nextTask = nextTaskList[0];
          l.Next_Action__c = nextTask.Subject;
          l.Next_Action_Date__c  = nextTask.ActivityDate;
        }
        else {
            l.Next_Action__c = null;
          l.Next_Action_Date__c  = null;
        }
        
        // set last completed task
        List<Task> lastTaskList = [SELECT Id, ActivityDate, Subject From Task Where (WhoId=:LeadId AND isDeleted=false AND Status='Completed') ORDER BY ActivityDate DESC LIMIT 1];
        if (!lastTaskList.isEmpty()) {
            Task lastTask = lastTaskList[0];
          l.Last_Action__c = lastTask.Subject;
          l.Last_Action_Date__c  = lastTask.ActivityDate;
        }
        else {
            l.Last_Action__c = null;
          l.Last_Action_Date__c  = null;
        }

        update l;
    }
}

Here is the Trigger:
 
trigger Kash_Task_Trigger on Task (after insert, after update, after delete, after undelete) {
    if (trigger.isInsert || trigger.isUndelete) {
        Kash_Task.processUpdate(trigger.new, null);        
    }
    else if (trigger.isUpdate) {
        Kash_Task.processUpdate(trigger.new, trigger.old);
    }
    else if (trigger.isDelete) {
        Kash_Task.processUpdate(null, trigger.old);
    }


 
I have read some posts on the forum, which use this as a demonstration of how to create good code coverage. http://amitsalesforce.blogspot.mx/2015/06/best-practice-for-test-classes-sample.html


I am using the Force.com Developer console, and when running tests the code coverage goes up to 40% or less, sometimes changing by 2%. The code not covered, according to the console has the following format:


 
if(Database.countQuery('SELECT count() FROM User WHERE User.Id = \''+ Object.variable+'\'') > 0)
             usr.add(Database.query('SELECT Id,Email FROM User WHERE User.Id = \''+ Object.variable +'\''));
Now how do have to code this from the test perspective? I have created SObjects accordingly in the test class, but even if I do, the console does not increase the code coverage for the class intended to be set in production.


 
Hi,

Can someone please help me in covering the test class for the below code and I have tried a lot to cover it to 100% but I am getting 81% 

public with sharing class COCaseComment
{
    public String test2 {get;set;}
    public String test1 {get;set;}
    public string status {get;set;}

    public void save() {
        Id caseId = ApexPages.currentPage().getParameters().get('caseid');
        SavePoint sp = Database.setSavePoint();
        status = 'unsaved';
        try {
            Case c = [SELECT Id,status,xyz1__c, xyz2__c FROM Case WHERE Id = :caseId FOR UPDATE];
            c.Status = 'Closed';
            insert new casecomment(ParentId = caseId, commentbody = 'Question:'+ '\n' + test1 + '\n' + 'solution :'+ '\n'+ test2 , IsPublished = true);
            update c;
            status = 'saved';
        } catch(Exception e) {
            Apexpages.addMessage(new ApexPages.message(Apexpages.Severity.Error, e.getMessage()));
            Database.rollback(sp);
        }
    }
}

Test class 

@isTest
public class TestCustomerOperationsCaseComment
{
    @isTest public static void withcaseid() {
        case c = new
        case (status = 'New', Origin = 'Phone', xyz1__c= 'AMR', xyz2__c = 'Charting Issues');
        insert c;
        case ca = [select id, status, xyz1__c ,xyz2__c from case where status = 'New'];
        Test.setCurrentPage(page.COcaseComment);
        COCaseComment cs = new COCaseComment();
        cs.Test1 = ('test1');
        cs.Test2 = ('test2');
        apexpages.currentPage().getparameters().put('caseid', ca.id);
        if (ca.id != null) {
            cs.save();
        }
        casecomment cm = [select commentbody, isPublished from casecomment where parentid =: ca.Id];
        string str = 'Question:'+ '\n' + test1 + '\n' + 'solution:'+ '\n'+ test2 ;
        system.assertEquals(str, cm.CommentBody);
        system.assert(true, cm.ispublished);
        case g = [select Status from case where ID = :ca.Id ];
        system.assertEquals('Closed', g.status);
    }


    @isTest static void caseWithoutproduct() 
   {
      
            case c = new
            case (status = 'New', Origin = 'Phone', xyz2__c = 'Charting Issues');
            insert c;
            pagereference pr = page.COcaseComment;
            pr.getParameters().put('caseid', c.Id);
            test.setCurrentPage(pr);
            COCaseComment cc = new COCaseComment();
            cc.save();
          System.assert(ApexPages.hasMessages(ApexPages.SEVERITY.Error));
         System.assertEquals('unsaved', cc.status);
    
    }
}



 
  • July 28, 2016
  • Like
  • 1
I am having a VF page and class and test class.I am getting 43% code coverage.How can i increae it?
Below is my aoex class which gets value from user on VF page and creates account.

When i debug the test classs,i am not getting account.name value even though i gave a.name='testaccount' in my test class.
So i am able to cover those lines of code.Please help me what am i missing.
 
public class new_classforpage {
    Public customobjectt__c pr{get;set;}
    
    Public string accountname{get;set;}
    public string contactname{get;set;}
    public string contactemail{get;set;}
   
    public Account account {get;set;}


    public new_classforpage(ApexPages.StandardController sc) {
    pr= (object__c )sc.getRecord();
    account=new account();
    }
    
    Public pagereference save(){
     upsert pr;

    if(accountname!= '' && accountname!= null){
      
        account.name=accountname;
       
        upsert account;
        
        contact c=new contact();
        c.accountid=account.id;
        c.lastName=contactname;
        c.Email=contactemail;;
        insert c;
            
        pr.account_Name__c=account.id;
        update Pr;
    }
    
   return new PageReference('/'+pr.Id+'/e?retURL=%2F'+pr.Id);   
    }
}

and this is my test class:
 
@istest
Public class test_classforpage{
    static testMethod void test(){
        test.startTest();        
        PageReference pref = Page.mypage;
        Test.setCurrentPage(pref);
        
        
        Account a =new account();

        a.name='accountname';
       
        if(a.name!= '' && a.name!= null){

        upsert a;
        
        contact c=new contact();
        c.lastname='test contact';
        c.accountid=a.id;
        c.email='testemail@gmail.com';
        insert c;
        
        Purchase_request__c pr =new Purchase_request__c();
        pr.account_Name__c=a.id;
        
        insert pr;
        
        update pr;

        // Instantiate standard Controller
        ApexPages.StandardController sc = new ApexPages.StandardController(pr);

        // Instantiate controller extension
        myclass  mc = new myclass (sc);
                
        mc.save();
           test.stopTest();
}
     }
}


 
I have a formula field that calculates the value of 2 date/time fields when subtracted 
TEXT(FLOOR( (Paused_End__c - Paused_Start__c) * 24 )) & " Hours " &
TEXT(ROUND((( (Paused_End__c - Paused_Start__c) * 24 )* 60),0)) & " Minute"

and its result is "23  Hours 20 Minute"

How can i add the days as well, what function formula will I use so it will show "2 Days 23 Hours 20 Minute"

Hello,

I need help on some calculation for my trigger.

Basically, what I would like to do is to get value like if the Result is 16, then this will round to 30, if it's 24 then it will still be 30, if the value is 32 then it will be 45.

What I did was :

integer x = 32;
double y = doubleValueOf(x - math.mod(x)) + 15;

But this doesn't seem to be consistent. Can I have some other sure approach to achieve this?


Thanks

Hi,

Can anyone suggest me a better formula? This is working fine, however I wanted to see if I get a better formula as it is lengthy one.

CASE( MS_Score__c ,
"0",Profile_Score__c +MS_Score__c,
"1",Profile_Score__c +MS_Score__c,
"2",Profile_Score__c +MS_Score__c,
"3",Profile_Score__c +MS_Score__c,
"4",Profile_Score__c +MS_Score__c,
"A0",Profile_Score__c +RIGHT(MS_Score__c,1),
"A1",Profile_Score__c +RIGHT(MS_Score__c,1),
"A2",Profile_Score__c +RIGHT(MS_Score__c,1),
"A3",Profile_Score__c +RIGHT(MS_Score__c,1),
"A4",Profile_Score__c +RIGHT(MS_Score__c,1),
"B1",Profile_Score__c +RIGHT(MS_Score__c,1),
"B2",Profile_Score__c +RIGHT(MS_Score__c,1),
"B3",Profile_Score__c +RIGHT(MS_Score__c,1),
"B4",Profile_Score__c +RIGHT(MS_Score__c,1),
"C0",Profile_Score__c +RIGHT(MS_Score__c,1),
"C1",Profile_Score__c +RIGHT(MS_Score__c,1),
"C2",Profile_Score__c +RIGHT(MS_Score__c,1),
"C3",Profile_Score__c +RIGHT(MS_Score__c,1),
"C4",Profile_Score__c +RIGHT(MS_Score__c,1),
"D1",Profile_Score__c +RIGHT(MS_Score__c,1),
"D2",Profile_Score__c +RIGHT(MS_Score__c,1),
"D3",Profile_Score__c +RIGHT(MS_Score__c,1),
"D4",Profile_Score__c +RIGHT(MS_Score__c,1),
"E0",Profile_Score__c +RIGHT(MS_Score__c,1),
"E1",Profile_Score__c +RIGHT(MS_Score__c,1),
"E2",Profile_Score__c +RIGHT(MS_Score__c,1),
"E3",Profile_Score__c +RIGHT(MS_Score__c,1),
"E4",Profile_Score__c +RIGHT(MS_Score__c,1),
"U0",Profile_Score__c +RIGHT(MS_Score__c,1),
"U1",Profile_Score__c +RIGHT(MS_Score__c,1),
"U2",Profile_Score__c +RIGHT(MS_Score__c,1),
"U3",Profile_Score__c +RIGHT(MS_Score__c,1),
"U4",Profile_Score__c +RIGHT(MS_Score__c,1),
""
)
Regards,
Ajay