• SimonJai
  • NEWBIE
  • 135 Points
  • Member since 2013

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

I want to concatenate two object IDs in order to make a hash value for a map, but this doesn't work:

 

conversionMap.put(entry.Pricebook2Id + entry.Product2Id), entry);

If I could convert the IDs to strings first, then I should be able to concatenate them in this way.  But, while there is a function to convert a string to an ID, I can't find any way to convert an ID to a string.  Anybody know how to do that?  Or, a better way to do what I'm trying to do?

 

Hi

I have written a trigger which will update the child field record whenevr the one parent fiel record changes..please help my code is not working...

trigger triggerupdate on Project__c(after update) {  
   
    for(project__c prj: trigger.new)
    {
   
if(trigger.oldmap.get(prj.Id).Dev_Lead_User__c!=trigger.newmap.get(prj.Id).Dev_Lead_User__c)
{    List<Quality_of_Delivery__c> Lstqod=new List<Quality_of_Delivery__c>();
    Lstqod=[Select project__c,Name,Dev_lead__c from Quality_of_Delivery__c where project__c=: prj.Id];
    List<Quality_of_Delivery__c> qodToupdate=new List<Quality_of_Delivery__c>();
    for(Quality_of_Delivery__c thisqod: Lstqod)
        {
           
                {
                    thisqod.Dev_lead__c=prj.Dev_Lead_User__c;
                    qodToupdate.add(thisqod);
                }
        }
}
    
    
    
     
    }
}

In a visual force page i need to create mutiple cases with associated attachment with each case is it possible????

Please reply asap.

 

hi every one, need ur help

 

When i m sending the hard code xml data through http,in response i m getting the status is ok n status code is 200,but the xml data is going to the external server in some encoded form.I m not using any encoding(like UTF-8) in my code,but still the external server getting xml in encoded form. 

 

Can any one tell me,how to remove this problm,cos if the external server receives the correct xml format data it will response back to correct value,for which i m looking.

 

Hi there,

 

I'm new in Apex, so I'm facing a few challenges in developer.

 

I have a picklist with a few options to choose.

Depending what option you choose in picklist a rule forces you to write in text field. So I already did a VR in the fields.

 

But what I really need in this fields is that they have to remain invisibles until user choose a option in picklist.

And I tryed programming this:

 

trigger Campos_Em_Branco on Case (before insert) {
//1.Dados de retorno is blank until I choose Motivo = Cheque devolvido
<apex:motivo__c value=Cheque devolvido>;
<apex:actionSupport action=On Case reRender=Dados de retorno/>;
</apex:motivo__c>;
<apex:motivo__c value=Cheque devolvido id=Dados_de_retorno__c rendered={!putaBooleanFlagifFieldisChanged} >
}

 

A friend sent the programming and I edit some things.

I think I'm in the right way.

But the programming still giving errors.

 

Can someone help me? What I'm doing wrong?

 

Thanks for help,

Everton.

Hi there,

 

Wrote a custom controller to display an overall view of all our services, but the test method is returning a "System.NullPointerException: Attempt to de-reference a null object" on this line:

 

@IsTest(SeeAllData=true)
public static void testServiceTimeline() {				
		
	ServiceTimeline controller = new ServiceTimeline();		
		
}

 

This is my controller:

 

public class ServiceTimeline {
	
	public List<ServiceTime> serviceList { get; set; }
	
	public ServiceTimeline() {
		
		List<Service__c> ListOfServices= [
			SELECT 
				Name, 
				RecordType.Name,
				Address_Single_Line__c,
				Status__c,
				CreatedDate,
				Stage_Prospect__c, 
				Stage_Site_Survey__c, 
				Stage_Scheduling_Install__c, 
				Stage_Provisioning__c, 
				Stage_Pending_Billing__c, 
				Stage_Order_Received__c, 
				Stage_Order_Completion__c, 
				Stage_Obtaining_Install_Approval__c, 
				Stage_Awaiting_Install__c,
				Stage_Design_Request__c
			FROM 
				Service__c 
			WHERE 
				Status__c NOT IN ('Order Completion', 'Cancelled', 'Stalled', 'Unserviceable')
				AND RecordType.Name NOT IN ('Prospect','Ethernet Interconnect')
			];
		
		if (ListOfServices.size() > 0) {
			for (Service__c tempService : ListOfServices) {
				serviceList.add(new ServiceTime(tempService));
			}
		} else {
			Util.addERRORMessage('No Services are currently being installed.');
		}
		
	}
}

 

Any help would be appreciated.

 

Hi there,

 

Wrote a custom controller to display an overall view of all our services, but the test method is returning a "System.NullPointerException: Attempt to de-reference a null object" on this line:

 

@IsTest(SeeAllData=true)
public static void testServiceTimeline() {				
		
	ServiceTimeline controller = new ServiceTimeline();		
		
}

 

This is my controller:

 

public class ServiceTimeline {
	
	public List<ServiceTime> serviceList { get; set; }
	
	public ServiceTimeline() {
		
		List<Service__c> ListOfServices= [
			SELECT 
				Name, 
				RecordType.Name,
				Address_Single_Line__c,
				Status__c,
				CreatedDate,
				Stage_Prospect__c, 
				Stage_Site_Survey__c, 
				Stage_Scheduling_Install__c, 
				Stage_Provisioning__c, 
				Stage_Pending_Billing__c, 
				Stage_Order_Received__c, 
				Stage_Order_Completion__c, 
				Stage_Obtaining_Install_Approval__c, 
				Stage_Awaiting_Install__c,
				Stage_Design_Request__c
			FROM 
				Service__c 
			WHERE 
				Status__c NOT IN ('Order Completion', 'Cancelled', 'Stalled', 'Unserviceable')
				AND RecordType.Name NOT IN ('Prospect','Ethernet Interconnect')
			];
		
		if (ListOfServices.size() > 0) {
			for (Service__c tempService : ListOfServices) {
				serviceList.add(new ServiceTime(tempService));
			}
		} else {
			Util.addERRORMessage('No Services are currently being installed.');
		}
		
	}
}

 

Any help would be appreciated.

 

I want to concatenate two object IDs in order to make a hash value for a map, but this doesn't work:

 

conversionMap.put(entry.Pricebook2Id + entry.Product2Id), entry);

If I could convert the IDs to strings first, then I should be able to concatenate them in this way.  But, while there is a function to convert a string to an ID, I can't find any way to convert an ID to a string.  Anybody know how to do that?  Or, a better way to do what I'm trying to do?

 

Hi,

 

I need the App name in my Controller class. I got the App name in my visualforce page by using the below javascript&colon;

 

var myappname = document.getElementById("tsidLabel").innerText;

 

But i want the app name in my controller class to check for the currently selected app.

 

Can any one help me out?

Hi Salesforce Community,


I got an error list apex with a SoQL script using multiple sObjects: Opportunity & OpportunityLineItems.
Script:

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

SELECT Amount, Name, ( SELECT Quantity, ListPrice,PriceBookEntry.ProductCode, PriceBookEntry.UnitPrice,TotalPrice, PricebookEntry.Name,PricebookEntry.product2.Family FROM OpportunityLineItems ) FROM Opportunity where id ='006i00000026VOj'

--------------------------
It is all the data that I need to show into a table visualforce page. But the list apex class, has an error. : Illegal assignment from LIST<Opportunity> to LIST<OpportunityLineItem>


I think this happens because maybe I need 2 lists to each sObjects. Actually I am using just 1 list with all my script SoQL.

Apex:

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

public class clsPaginaPedidos {

    public Opportunity opp {get;set;}    

   List<OpportunityLineItem> OpportunityLineItem;  //List        

 

public List<OpportunityLineItem> getOpportunityLineItem() { 

 if(OpportunityLineItem == null) OpportunityLineItem = [SELECT Amount, Name,

(SELECT Quantity, ListPrice,PriceBookEntry.ProductCode, PriceBookEntry.UnitPrice,TotalPrice, PricebookEntry.Name, PricebookEntry.product2.Family FROM OpportunityLineItems)

FROM Opportunity where id = :ApexPages.currentPage().getParameters().get('id')];
   

return OpportunityLineItem;         

    }//End List  

 

}//End class

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


Any help??

Thanks,

   Luis.

I have a trigger that works awesome when I insert a record.  The problem is when I update the parent record, the child records do not populate.

I am quite new to triggers.

 

The scenario:

   A Renewal may / may not be ammoritzed over "x" amount of months.

   If renewal is amoritzed, then "Number of months to amortize over" must be entered. (Validation rule covers this)

   On save, the trigger inserts the number of child records into Renewal Payments equal to the number of months to amoritze over.

 

The problem:

    This works fantastic if I am inserting a new record.  But if later, I decide to edit an existing record to amortize over, the trigger doesnt fire.  I know that this is because of how I have my current trigger defined (see below) but I dont get how to do an after (or before?) update to solve the problem.  Can someone help me out?

 

Existing trigger:

trigger renewalAmortPayments on Renewal_Year__c (after insert) {
   List<Renewal_Payment__c> listInsertPayments = new List<Renewal_Payment__c>();
   for(Renewal_Year__c objPayment:Trigger.New) {
       if(objPayment.Number_of_Months_to_Amortize_over__c != NULL) {
           Decimal decVal = objPayment.Number_of_Months_to_Amortize_over__c -1;
           Integer iCount = Integer.ValueOf(decVal);
           for(integer i = 0; i <= iCount; i++){
               Renewal_Payment__c objRenPay = New Renewal_Payment__c();
               objRenPay.Renewal_Year__c = objPayment.id;
               objRenPay.Payment_Number__c = i;
               listInsertPayments.add(objRenPay);
           }
       }
    }
    if(listInsertPayments.size()>0) { insert listInsertPayments; }
}

 Some extra info:

 

 There is a date calc field on the existing child object that requires me to use the "Decimal decVal = objPayment.Number_of_Months_to_Amortize_over__c -1;" line.  I need to be able to enter the records on INSERT of original record on UPDATE of existing Renewal_Year__c record, and possibly to delete Renewal_Payments__c records if there is an error discovered after user saves initial record.

 

Anyone have some help for me?  I would appreciate it. 

 

Thanks,

Temple

Hello - I have a trigger that inserts a task in my opportunity when the opp is cloosed won. Now i need to eclude users with a role = inside sales. i have it in there but it is not working?

 

Also - i need help bringing my code up to 100%

 

any help would be awesome. Thank you

 

public class TasksForOpportunitiesClosedToContracts 
{
    public static void createTasksForOpportunityClosedToContract(Opportunity[] opportunities)
    {
        RecordType RecType = new RecordType();  
        RecType = [SELECT ID FROM RecordType WHERE Name = 'SAM Task'];
        

        for (Integer i = 0; i < opportunities.size(); i++) 
        {
            IF (opportunities[i].StageName == 'Closed Won' &&
                opportunities[i].LeadSource != 'Purchased from Site' &&
                opportunities[i].Message_Sent__c == false &&
                opportunities[i].Owner.UserRole.Name !='Inside Sales Representative'&&
                opportunities[i].Count_of_Pending_RS__c==0) 
            {
                Account acct = new Account();
                Task newContractTask = new Task();                
                
                acct = [SELECT client_id__c FROM Account WHERE ID = :opportunities[i].AccountId];
                                
                newContractTask.client_id__c = acct.client_id__c;
                newContractTask.OwnerID = opportunities[i].Account_Manager__c;
                newContractTask.Subject = 'New Closed Won Opportunity';
                newContractTask.Description = opportunities[i].Description;
                newContractTask.WhatID = opportunities[i].ID;
                newContractTask.Status = 'Not Started';
                newContractTask.RecordTypeID = RecType.ID;
                newContractTask.Priority = 'High';
                newContractTask.Type = 'New Closed Won Opportunity';
                newContractTask.ActivityDate = system.today();
                newContractTask.reminderdatetime = system.now();
                newContractTask.isreminderset = false;
                newContractTask.Short_Description__c = 'Create Contract/ Activate Job';
    
                insert newContractTask;

                
            } 
            
        } 
      } 
    
    static testMethod void test_trTasksForOpportunitiesToContracts()
    {
        Opportunity candidateOpportunity = [Select opp.StageName, opp.LeadSource From Opportunity opp 
                                            where opp.StageName != 'Closed Won' 
                                            and opp.StageName != 'Closed Lost' 
                                            and opp.Billing_is_different_than_Account__c = false 
                                            LIMIT 1];
        candidateOpportunity.StageName = 'Closed Won';
        candidateOpportunity.Billing_Email__c = 'test@healthecareers.com';
        candidateOpportunity.Billing_Contact__c = 'Test Contact' ;
        candidateOpportunity.Invoice_Delivery_Method__c = 'Email';
        candidateOpportunity.Payment_Method__c = 'Invoice';
        candidateOpportunity.Billing_Contact__c = 'Test Contact' ;
        candidateOpportunity.Type = 'Renewal';
        candidateOpportunity.New_Dollar_Amount__c =0;
        candidateOpportunity.Win_Loss_Notes__c = 'These are test notes.';
        update candidateOpportunity;
        
        Task newContractTask = [select Type from Task where WhatId = :candidateOpportunity.Id and Subject = 'New Closed Won Opportunity' LIMIT 1];
        System.assertEquals('New Closed Won Opportunity', newContractTask.Type);
        
    }
    
    
}

 

I'm just getting started with Apex and am having a little trouble getting my first test class past 57%. The test is for a very simple custom controller for a visualforce page which returns a list of values from an SOQL query, then updates any records that are modified. The controller works fine, and I've poured over all the developer documentation and board posts I can find but still can't get the test to fly.

 

I intend to improve my Apex knowledgebase with some additional training but in the meantime really need to get this one class up and running. Any help would be greatly appreciated. My current code is below:

 

Custom Controller:

public class plantListingClass {
  
    public Account[] accts = new Account[0];

  public Account[] getAccts() {
        
        accts = [SELECT ID, Parent.Name, Name, BillingState, Logo__c,  
        Category__c, Report_Classification__c, Region__c, Comments__c, Status_Update__c, 
        Last_Update__c 
        FROM Account 
        WHERE Report_Classification__c = 'Existing Plant' 
        ORDER BY Region__c DESC, Logo__c, Parent.Name];
        RETURN accts;       
    }

public PageReference save() {
     UPDATE accts;
     return null;
    }     
    
}

 Visualforce Page:

<apex:page controller="plantListingClass" tabstyle="account" sidebar="false">
   <font size="6">
   Activity Report: Existing Plants
   </font>
    <BR /> <BR />      

   
   <apex:form >
 
   <apex:pageBlock >
 
   <apex:pageMessages />
   <apex:pageBlockSection title="Existing Plants"/>
   <apex:pageBlockTable value="{!accts}" var="a">
      <apex:column value="{!a.Region__c}"/> 

      <apex:column headerValue="Parent">
         <apex:outputField value="{!a.Logo__c}"/>
      </apex:column>          

      <apex:column headerValue="Company">
         <apex:outputField value="{!a.Parent.Name}"/>
      </apex:column>                 

      <apex:column headerValue="Plant">
         <apex:outputField value="{!a.Name}"/>
      </apex:column>   
            
      <apex:column headerValue="State">
         <apex:outputField value="{!a.BillingState}"/>
      </apex:column> 
            
    
      <apex:column value="{!a.Last_Update__c}"/>                 
      <apex:column headerValue="Status Update">
         <apex:inputField value="{!a.Status_Update__c}"/>
      </apex:column>
      <apex:column headerValue="Comments">
         <apex:inputField value="{!a.Comments__c}"/>
      </apex:column>
 
   </apex:pageBlockTable>
  <apex:pageBlockButtons >
      <apex:commandButton value="Save" action="{!save}"/>
      </apex:pageBlockButtons>  
   </apex:pageBlock>
   </apex:form>
Report Generated: <apex:outputText value="{!NOW()}"></apex:outputText>    
</apex:page>

 Test Class:

@isTest
private class plantListingTest {
    static testMethod void validatePlantListingClass() {
 
 
     Account testAccount = new Account(Name='Test Company Name',
                                        Category__c = 'Customer / Prospect',
                                        Report_Classification__c = 'Existing Plant',
                                        Region__c = 'West Region',
                                        Comments__c = 'Test Comments',
                                        Status_Update__c = 'Pending Bid',
                                        billingState='AZ');
     insert testAccount;
       
     testAccount.billingState='CA';
     update testAccount;

     // Verify that the billingState field was updated in the database.
     Account updatedAccount = [SELECT billingState FROM Account WHERE Id = :testAccount.Id];
     System.assertEquals('CA', updatedAccount.billingState);
        
        plantListingClass ctrl = new plantListingClass();
        
        Integer accSize = ctrl.getAccts().size();
        System.assert (accSize >= 1);
        
    
    

    }


}

 Here is my code coverage report:

 

Hi,

I have a situation like make the record as Read on a object (when <object>.<Technical Agency>.<Vendor Name> = <Dev_Lead>.<CompanyName> )..

there is a fied Technical Agency which is lookup to vendor and the Dev_Lead__c is lookup to user.

 

how to write the sharing for this situation please help

In a visual force page i need to create mutiple cases with associated attachment with each case is it possible????

Please reply asap.

 

Hi there,

 

I'm new in Apex, so I'm facing a few challenges in developer.

 

I have a picklist with a few options to choose.

Depending what option you choose in picklist a rule forces you to write in text field. So I already did a VR in the fields.

 

But what I really need in this fields is that they have to remain invisibles until user choose a option in picklist.

And I tryed programming this:

 

trigger Campos_Em_Branco on Case (before insert) {
//1.Dados de retorno is blank until I choose Motivo = Cheque devolvido
<apex:motivo__c value=Cheque devolvido>;
<apex:actionSupport action=On Case reRender=Dados de retorno/>;
</apex:motivo__c>;
<apex:motivo__c value=Cheque devolvido id=Dados_de_retorno__c rendered={!putaBooleanFlagifFieldisChanged} >
}

 

A friend sent the programming and I edit some things.

I think I'm in the right way.

But the programming still giving errors.

 

Can someone help me? What I'm doing wrong?

 

Thanks for help,

Everton.