• Shivani Desai
  • NEWBIE
  • 20 Points
  • Member since 2014
  • Salesforce Administrator
  • Amplify Access

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 16
    Replies
Hi,

I have a validation rule where in am trying to control the opportunity from moving to a 100%(closed won) if the stage is not changed by the legal department. The legal department has to verify some of the documents before the contract is signed. Somehow the sales team is able to change the probability irrespective of the validation.

My validation rule
AND( OR(ISCHANGED( StageName )) , OR( ISPICKVAL( StageName ,"PO/Signed Contract"), ISPICKVAL( StageName,"POC Signed Contract") ), $User.Id<>"005G0000002kon2",$User.Id<>"005G0000002iftc")

Checks if the stagename is changed to either of these  picklist values and whether the user id does not belong to one of these two users.

Can anyone please help me? Am doing something wrong but unable to detect what?
Hi,

I am constantly getting this error in a test class no matter how many changes I make or how many times I try to get the current page Id. Guess am having trouble writing the correct syntax or order. Any help will be greatly appreciated. My visualforce page is creating a record and then creating or updating child records for the record created using csv upload.
This is my controller code 
public with sharing class FileUploader1
{
  
    private final Sobject parent;
    public string nameFile{get; set;}
    public Blob contentFile{get;set;}
    //public String theId;
    public List<gii__InventoryAdjustment__c> adj;
    public List<gii__ProductSerial__c> accstoupload;
    String[] filelines = new String[]{};
    private ApexPages.standardController standardController;
   
    public String theId = ApexPages.currentPage().getParameters().get('id');
   
    public FileUploader1(ApexPages.StandardController stdcontroller) {
          }
   
  //public FileUploader1(string n, blob c) {
    //this.namefile = n;
    //this.contentfile = c;
    //}
       
    public Pagereference ReadFile()
    {           
        nameFile=contentFile.toString();
        filelines = nameFile.split('\n');
       
       
       
        accstoupload = new List<gii__ProductSerial__c>();
        Integer size = filelines.size()-1;
       
        gii__InventoryAdjustment__c []adj = [SELECT gii__Warehouse__c,gii__Product__c,gii__ProductInventory__c FROM gii__InventoryAdjustment__c WHERE Id = :TheId];
      

       
        for (Integer i=1;i<filelines.size();i++)
        {
           
            String[] inputvalues = filelines[i].split(',');
            String name = inputvalues[0].trim();
            String Carton = inputvalues[1].trim();
            String Pallet = inputvalues[2].trim();
            String MBSerial = inputvalues[3].trim();
            string Mydate = inputvalues[4].trim();
            string Model = inputvalues[5].trim();
            String Refurbished = inputvalues[6].trim();
            //string school = inputvalues[7].trim();
            string price = inputvalues[7].trim();
           
                     
           
           
                       
            gii__ProductSerial__c a = new gii__ProductSerial__c();
            a.Name = name;
            a.CARTON_NO__c = Carton;
            a.PALLET_NO__c= Pallet;
            a.MBSERIAL_Number__c = MBSerial;
            a.Manufacturer_Date__c = date.parse(Mydate);
            a.Model__c = model;
            a.Refurbished__c = Refurbished;
            a.Price__c = price;
            a.gii__InventoryAdjustment__c = adj[0].Id;
            a.gii__Product__c = adj[0].gii__Product__c;
            a.gii__ProductInventory__c = adj[0].gii__ProductInventory__c;
            a.gii__Warehouse__c = adj[0].gii__Warehouse__c;
            a.gii__TransactionType__c = 'Inventory Adjustment';
          //  a.School_Registered_At__c = school;
           
            accstoupload.add(a);
           
        }
        try{
        upsert accstoupload MBSERIAL_Number__c ;
        }
         catch (Exception e)
        {
            ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured. Please check the template or try again later');
            ApexPages.addMessage(errormsg);
        }
     
       
       
    return null;
    }
  
}

And my test class is as follows
@isTest(SeeAllData = true)
private class FileUploader1Test {

    public static testmethod void constructorTest() {
   
    gii__InventoryAdjustment__c adj = new gii__InventoryAdjustment__c();
    adj.gii__AdjustmentQuantity__c = 20;
      adj.gii__AdjustmentDate__c = System.today();
      adj.gii__ProductInventory__c = 'a1c11000000AJM7';
      adj.gii__Reason__c = 'Inventory Adjustment';
      insert adj;

      PageReference pgRef = Page.Inventory_Adjustment_Another;
      //use the page reference Apex Class to instantiate a page named Inventory_Adjustment_Another
    
      Test.setCurrentPage(pgRef);
      //set the filled values for adj
     
      ApexPages.StandardController thecontroller = new ApexPages.StandardController(adj);
      //Initiation of the controller
     
      FileUploader1 controller = new FileUploader1(thecontroller);
      //the controller
    
      system.assert(thecontroller != null);
     
      thecontroller.save();
      String TheId = ApexPages.currentPage().getParameters().put('ID',adj.id);
       //blob forcontent = blob.valueof(blobcreator);
               
       String blobCreator =  '90JV1300002H42100650,G642109162,P452805539,EG451507895,6/15/2014,CD3,No,199' + '\r\n' +
                                '90JV1300002H42100651,G642109193,P452805539,EG451507643,6/15/2014,CD3,No,199'+ '\r\n' +
                                '90JV1300002H42100652,G642109162,P452805539,EG451507672,6/15/2014,CD3,No,199' + '\r\n' +
                                '90JV1300002H42100653,G642109161,P452805539,EG451507677,6/15/2014,CD3,No,199';
        
        blob forcontent = blob.valueof(blobcreator);
        controller.contentFile = forcontent;
        controller.nameFile = blobCreator;
        ApexPages.currentPage().getParameters().put('id', adj.id);
       
        Controller.ReadFile();
              
      
      }
}

this is the error that I am recieving" List index out of bounds: 0". Greatly appreciate any help possible.


I am looking for a little help I am pretty much brand new to VF and other than training I have never actually done anything functional in it.  I am trying to create a form from a custom object but keep getting the error Coul not resolvve the entity from <apex:inputField> value binding '{!Initial_Investment_Costs__c}", <apex:inputField> can only be sused with SObjects, or objects that are Visualforce field component resolvable.  But I cannot figure out what is the problem.  My VF page is below.

<apex:page standardController="CapEx_OpEx_Initial_Investment_Costs__c">
    <apex:form>
        <apex:pageBlock title="Add Initial Investment Costs">
            <apex:inputField value="{! Initial_Investment_Costs__c}"/>
            <apex:inputField value="{! If_Other_Please_Specify__c}"/>
            <apex:inputField value="{! Year_0__c}"/>
            <apex:inputField value="{! Year_1__c}"/>
            <apex:inputField value="{! Year_2__c}"/>
            <apex:inputField value="{! Year_3__c}"/>
            <apex:inputField value="{! Additional_Notes__c}"/>
             
            <apex:pageBlockButtons>
                <apex:commandButton action="{! save }" value="Save" />  
                <apex:commandButton action="{! save&New }" value="Save & New" />   
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
When an Account has the value of 'Prospect' in the Type field, a user will click the 'Submit for Approval' button to launch an approval process. The process will only happen if Type is 'Prospect' and there are more than 500 employees. Upon entry of the process, Type will become 'Pending' and be locked. If approved, Type will be set to 'Customer' and be unlocked. If not approved, Type will be set back to 'Prospect' and will be unlocked.

The Account object's Type field must have the following picklist values: Prospect, Customer, Pending. Before creating the approval process, verify the values in your Account object setup
The approval process name must be 'Approve New Account'.
When user click 'Submit for Approval', the approval must be processed if the Type field is set to 'Prospect' and the value of Employees is greater than 500.
Upon entering the approval process, set the Type field to 'Pending' and lock the record.
Normally the approver would be someone else. In this instance, assign yourself to be the approver.
If approved, set the Type field to 'Customer' and unlock the record.
If not approved, set the Type field back to 'Prospect', and unlock the record.

could you Please explain how to create approval process?

Suresh.N
I am trying to make a very simple code change to something completely unrelated to the Public Knowledge Base App (third party from app exchange) and I am getting the following error that is preventing me from deploying:

System.AssertException: Assertion Failed
class.pkb_mobile_Test.test_getArticleDetail: line 290, column 1

I checked out the code for this and the whole test looks like so:
 
//public static pkb_mobile_proxy.ResponseItem getArticleDetail(pkb_mobile_proxy.RequestItem req){
	@isTest(SeeAllData=true)
	static void test_getArticleDetail() {
		
		pkb_mobile_proxy.ResponseItem resp = null;

		//with setup
		populatePKB2Environment();
		PKB__c pkS = populateSetup();
		pkb_Controller.DEFAULT_SITE_NAME = siteName;
		pkb_Controller pc = pkb_mobile_controller.setUp();

		//build request object
		pkb_mobile_proxy.RequestItem req = new pkb_mobile_proxy.RequestItem();
		req.lang = KnowledgeArticleVersion.Language.getDescribe().getPickListValues().get(0).getValue();
		req.operationType = 'getArticleDetail';
		req.sessionId = 'TESTSESSION';
		req.searchCriteria = String.valueOf(kavObj.get('KnowledgeArticleId'));
		resp = pkb_mobile_controller.getArticleDetail(req);
 		
 		system.assert(resp.isSuccess);
 		
 		Map<String,String> fieldValues = (Map<String,String>)resp.articleData.fieldValues;
 		String kavTitle = String.valueOf(kavObj.get('title'));
 		String resultTitle = resp.articleData.title;
		system.assert( resultTitle.contains(kavtitle));
		
		//with null request 
		resp = pkb_mobile_controller.getArticleDetail(null);
		system.assert(!resp.isSuccess);

	}

I have not made any code changes to any of the PKB code, so I have to assume it is something in setup in the UI. Any help would be greatly appreciated. 

Thanks!
 

Hi All,
We would like to calculate the age of our lead but have it start over from zero each time the status changes.  E.g.  if a lead is "Open" for 3 days and then changed to "Contacted" and stays "Contacted" for 2 days, we would like to have "Open" = 0o and "Contacted" = 2.  We have already created the fields for each of our statuses... just need help building the formula now.

Thanks!

Jamie
 

Hi,

I have a validation rule where in am trying to control the opportunity from moving to a 100%(closed won) if the stage is not changed by the legal department. The legal department has to verify some of the documents before the contract is signed. Somehow the sales team is able to change the probability irrespective of the validation.

My validation rule
AND( OR(ISCHANGED( StageName )) , OR( ISPICKVAL( StageName ,"PO/Signed Contract"), ISPICKVAL( StageName,"POC Signed Contract") ), $User.Id<>"005G0000002kon2",$User.Id<>"005G0000002iftc")

Checks if the stagename is changed to either of these  picklist values and whether the user id does not belong to one of these two users.

Can anyone please help me? Am doing something wrong but unable to detect what?
Hi,

I am constantly getting this error in a test class no matter how many changes I make or how many times I try to get the current page Id. Guess am having trouble writing the correct syntax or order. Any help will be greatly appreciated. My visualforce page is creating a record and then creating or updating child records for the record created using csv upload.
This is my controller code 
public with sharing class FileUploader1
{
  
    private final Sobject parent;
    public string nameFile{get; set;}
    public Blob contentFile{get;set;}
    //public String theId;
    public List<gii__InventoryAdjustment__c> adj;
    public List<gii__ProductSerial__c> accstoupload;
    String[] filelines = new String[]{};
    private ApexPages.standardController standardController;
   
    public String theId = ApexPages.currentPage().getParameters().get('id');
   
    public FileUploader1(ApexPages.StandardController stdcontroller) {
          }
   
  //public FileUploader1(string n, blob c) {
    //this.namefile = n;
    //this.contentfile = c;
    //}
       
    public Pagereference ReadFile()
    {           
        nameFile=contentFile.toString();
        filelines = nameFile.split('\n');
       
       
       
        accstoupload = new List<gii__ProductSerial__c>();
        Integer size = filelines.size()-1;
       
        gii__InventoryAdjustment__c []adj = [SELECT gii__Warehouse__c,gii__Product__c,gii__ProductInventory__c FROM gii__InventoryAdjustment__c WHERE Id = :TheId];
      

       
        for (Integer i=1;i<filelines.size();i++)
        {
           
            String[] inputvalues = filelines[i].split(',');
            String name = inputvalues[0].trim();
            String Carton = inputvalues[1].trim();
            String Pallet = inputvalues[2].trim();
            String MBSerial = inputvalues[3].trim();
            string Mydate = inputvalues[4].trim();
            string Model = inputvalues[5].trim();
            String Refurbished = inputvalues[6].trim();
            //string school = inputvalues[7].trim();
            string price = inputvalues[7].trim();
           
                     
           
           
                       
            gii__ProductSerial__c a = new gii__ProductSerial__c();
            a.Name = name;
            a.CARTON_NO__c = Carton;
            a.PALLET_NO__c= Pallet;
            a.MBSERIAL_Number__c = MBSerial;
            a.Manufacturer_Date__c = date.parse(Mydate);
            a.Model__c = model;
            a.Refurbished__c = Refurbished;
            a.Price__c = price;
            a.gii__InventoryAdjustment__c = adj[0].Id;
            a.gii__Product__c = adj[0].gii__Product__c;
            a.gii__ProductInventory__c = adj[0].gii__ProductInventory__c;
            a.gii__Warehouse__c = adj[0].gii__Warehouse__c;
            a.gii__TransactionType__c = 'Inventory Adjustment';
          //  a.School_Registered_At__c = school;
           
            accstoupload.add(a);
           
        }
        try{
        upsert accstoupload MBSERIAL_Number__c ;
        }
         catch (Exception e)
        {
            ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured. Please check the template or try again later');
            ApexPages.addMessage(errormsg);
        }
     
       
       
    return null;
    }
  
}

And my test class is as follows
@isTest(SeeAllData = true)
private class FileUploader1Test {

    public static testmethod void constructorTest() {
   
    gii__InventoryAdjustment__c adj = new gii__InventoryAdjustment__c();
    adj.gii__AdjustmentQuantity__c = 20;
      adj.gii__AdjustmentDate__c = System.today();
      adj.gii__ProductInventory__c = 'a1c11000000AJM7';
      adj.gii__Reason__c = 'Inventory Adjustment';
      insert adj;

      PageReference pgRef = Page.Inventory_Adjustment_Another;
      //use the page reference Apex Class to instantiate a page named Inventory_Adjustment_Another
    
      Test.setCurrentPage(pgRef);
      //set the filled values for adj
     
      ApexPages.StandardController thecontroller = new ApexPages.StandardController(adj);
      //Initiation of the controller
     
      FileUploader1 controller = new FileUploader1(thecontroller);
      //the controller
    
      system.assert(thecontroller != null);
     
      thecontroller.save();
      String TheId = ApexPages.currentPage().getParameters().put('ID',adj.id);
       //blob forcontent = blob.valueof(blobcreator);
               
       String blobCreator =  '90JV1300002H42100650,G642109162,P452805539,EG451507895,6/15/2014,CD3,No,199' + '\r\n' +
                                '90JV1300002H42100651,G642109193,P452805539,EG451507643,6/15/2014,CD3,No,199'+ '\r\n' +
                                '90JV1300002H42100652,G642109162,P452805539,EG451507672,6/15/2014,CD3,No,199' + '\r\n' +
                                '90JV1300002H42100653,G642109161,P452805539,EG451507677,6/15/2014,CD3,No,199';
        
        blob forcontent = blob.valueof(blobcreator);
        controller.contentFile = forcontent;
        controller.nameFile = blobCreator;
        ApexPages.currentPage().getParameters().put('id', adj.id);
       
        Controller.ReadFile();
              
      
      }
}

this is the error that I am recieving" List index out of bounds: 0". Greatly appreciate any help possible.


Can anyone provide a basic explanation of what Apex Code Coverage is, and how to increase it?
  • July 14, 2014
  • Like
  • 0
I am trying to display a text field ,'RESOURCE', from the master object (this text field is manually entered on the VF page associated to the master object). This needs to be displayed on another VF page associated to the child object. So, I have written a code like this on the VF page(related to child object):

<apex:pageBlockSection id="DetailsSection" columns="1"><apex:outputField id="Resource" value="{!Child_Object__c.Master_Object__r.Resource__c}"/></apex:pageBlockSection>

But, when I open the VF page, the value doesn't appear however once I save the page after entering the rest of the details and reopen it the value appears.

Hi,

I have to export data from the .csv file( in a shared folder) to the corresponding fields in my Salesforce account using Apex code.

Kindly advice me how to achieve this...
Also share if some sample codes are available.


Thanks in Advance
Ambily

  • April 21, 2010
  • Like
  • 0

On 2/10 I deployed a Visualforce page and Controller to Production using Eclipse. The deployment process validated the code and successfully deployed the page and class. I logged into Produciton and the page was working correctly.

 

I came back in on Monday and realized that I had not written any test cases but that the code had deployed succcessfully! I submitted a case but to this date L3 support cannot tell why this happened?

 

Can anyone explain how my code could be deployed to Production without any test cases (ie 0% coverage)?

 

Thanks

 

Jeff Douglas
Informa Plc
http://blog.jeffdouglas.com