• AdamSBeal
  • NEWBIE
  • 50 Points
  • Member since 2012

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 13
    Replies

I have a contact field on a custom object I am exposing in a visualforce page in our customer portal. I would like it so that contacts related to the logged in portal user show only. Currently they can search all accounts which isn't cool. Any ideas on how to make this happen? 

 

Thanks!

 

Adam

I have no idea what is causing this, but...

 

I used to be able to go to Apex Classes, and then  click the link that showed what percent of the code has been tested. Once clicked I could see in red what hasn’t been tested. Now when I do it, a blank page comes up and I have no idea what needs to be tested.

 

Any ideas?.... I have logged out/ logged in multiple times same issue. Tried in IE and Firefox.

 

I am passing some selected account Ids to my visualforce page in the querystring. I wish to add these to a related list in my visualforce page but I am getting an Invalid Id Error.  I am wondering if it is because my id is type string. The strange thing is when I hard code this same Id value it works. Any ideas?

Error:The following error occurred attempting to save:Invalid id: (001V000000606czIAA)

 

Here is the code:

 

String queryParamAccts = System.currentPagereference().getParameters().get('sAccts');

queryParamAccts = EncodingUtil.urlDecode(queryParamAccts, 'UTF-8');

 List<String> orderAccounts = queryParamAccts.split(',');
                 Set<Id> setAccountIds = new Set<Id>();
                 for(String s : orderAccounts)
                 {
                     setAccountIds.add(s); //error happens here
                 }

 Here is the debug log:

 

14:47:51.391 (391025000)|SYSTEM_METHOD_EXIT|[106]|System.debug(ANY)
14:47:51.391 (391095000)|SYSTEM_CONSTRUCTOR_ENTRY|[108]|<init>(Integer)
14:47:51.391 (391125000)|SYSTEM_CONSTRUCTOR_EXIT|[108]|<init>(Integer)
14:47:51.391 (391144000)|SYSTEM_METHOD_ENTRY|[109]|LIST<String>.iterator()
14:47:51.391 (391171000)|SYSTEM_METHOD_EXIT|[109]|LIST<String>.iterator()
14:47:51.391 (391184000)|SYSTEM_METHOD_ENTRY|[109]|system.ListIterator.hasNext()
14:47:51.391 (391199000)|SYSTEM_METHOD_EXIT|[109]|system.ListIterator.hasNext()
14:47:51.391 (391225000)|SYSTEM_METHOD_ENTRY|[111]|SET<Id>.add(Object)
14:47:51.391 (391287000)|EXCEPTION_THROWN|[EXTERNAL]|System.StringException: Invalid id: (001V000000606czIAA)
14:47:51.391 (391338000)|SYSTEM_METHOD_EXIT|[111]|SET<Id>.add(Object)
14:47:51.391 (391392000)|SYSTEM_METHOD_ENTRY|[132]|System.StringException.getMessage()
14:47:51.391 (391418000)|SYSTEM_METHOD_EXIT|[132]|System.StringException.getMessage()
14:47:51.391 (391487000)|SYSTEM_METHOD_ENTRY|[132]|ApexPages.addMessage(ApexPages.Message)
14:47:51.391 (391509000)|VF_PAGE_MESSAGE|The following error occurred attempting to save this order:Invalid id: (001V000000606czIAA)

I am passing some selected account Ids to my page in the querystring. I wish to add these to a list in my page but I am getting an Invalid Id Error.  I am wondering if it is because my id is type string. This is the error (The id is a valid account id): 

Error:The following error occurred attempting to save:Invalid id: (001V000000606czIAA)

 

Here is the code:

 

String queryParamAccts = System.currentPagereference().getParameters().get('sAccts');

queryParamAccts = EncodingUtil.urlDecode(queryParamAccts, 'UTF-8');

 List<String> orderAccounts = queryParamAccts.split(',');
                 Set<Id> setAccountIds = new Set<Id>();
                 for(String s : orderAccounts)
                 {
                     setAccountIds.add(s); //error happens here
                 }

 Here is the debug log:

 

14:47:51.391 (391025000)|SYSTEM_METHOD_EXIT|[106]|System.debug(ANY)
14:47:51.391 (391095000)|SYSTEM_CONSTRUCTOR_ENTRY|[108]|<init>(Integer)
14:47:51.391 (391125000)|SYSTEM_CONSTRUCTOR_EXIT|[108]|<init>(Integer)
14:47:51.391 (391144000)|SYSTEM_METHOD_ENTRY|[109]|LIST<String>.iterator()
14:47:51.391 (391171000)|SYSTEM_METHOD_EXIT|[109]|LIST<String>.iterator()
14:47:51.391 (391184000)|SYSTEM_METHOD_ENTRY|[109]|system.ListIterator.hasNext()
14:47:51.391 (391199000)|SYSTEM_METHOD_EXIT|[109]|system.ListIterator.hasNext()
14:47:51.391 (391225000)|SYSTEM_METHOD_ENTRY|[111]|SET<Id>.add(Object)
14:47:51.391 (391287000)|EXCEPTION_THROWN|[EXTERNAL]|System.StringException: Invalid id: (001V000000606czIAA)
14:47:51.391 (391338000)|SYSTEM_METHOD_EXIT|[111]|SET<Id>.add(Object)
14:47:51.391 (391392000)|SYSTEM_METHOD_ENTRY|[132]|System.StringException.getMessage()
14:47:51.391 (391418000)|SYSTEM_METHOD_EXIT|[132]|System.StringException.getMessage()
14:47:51.391 (391487000)|SYSTEM_METHOD_ENTRY|[132]|ApexPages.addMessage(ApexPages.Message)
14:47:51.391 (391509000)|VF_PAGE_MESSAGE|The following error occurred attempting to save this order:Invalid id: (001V000000606czIAA)

This is my first trigger and I am struggling with it.  I have a "OrderContract" custom object and it is attached to Account via a lookup field. I have a trigger on Opportunity that when a new opportunity is inserted if the record type is "Order" then it should do a lookup on the related account and get the OrderContract and populate that value into the related OrderContract field in the Opportunity.  Here is the code when I try to save it gives me this compile error:

 unexpected token: 'opportunityMap.get' at line 18 column 103

 

trigger SetContractOnOpportunity on Opportunity (after insert) 
{ 
  Map<Id, Opportunity> opportunityMap = new Map<Id, Opportunity>();
 
  RecordType rt = [select Id from RecordType where Name = 'Order' and SobjectType = 'Opportunity' limit 1];
 
  for (Opportunity oppNew : Trigger.new)
  {  
    if (oppNew.RecordType == rt && oppNew.Order_Contract__c != Trigger.oldMap.get(oppNew.Id).Order_Contract__c)
      opportunityMap.put(oppNew.Id, oppNew);
  }  
  
  if (opportunityMap.size() > 0)
  {  
      for (Opportunity opportunity : opportunityMap)
      {
           //pull the Order_Contract__c custom field defined on Account 
           List<Order_Contract__c> contractsList = [SELECT Order_Contract__c FROM Account where Id = opportunityMap.get(opportunity.Id).AccountId]; 
           opportunity.Order_Contract__c = contractsList;
        
      }
      update opportunityMap ;
   }
}

 

I am new at this so any help with how this trigger is wrong in general would be very much appreciated.

Thanks,

Adam

I am creating a MassEmailMessage and attempting to send a message to a list of contactIds. This code sends the emails as long as I don't set a whatId but the template isn't filled with data from my deviceID. When I set the whatIDs I get the "Attempt to de-reference a null object". I do call this after I have done the DML insert(devicerequest) and in debugging I can see a deviceRequest.Id is there when I call mail.WhatIds.add(deviceRequestId). Here is the code any help is greatly appreciated:

 

insert(deviceRequest);
EmailTemplate emailTemplate = [SELECT id FROM EmailTemplate WHERE DeveloperName = 'Device_Request'];
Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
mail.setSenderDisplayName(senderName); 
mail.setReplyTo(senderEmail);	
						
mail.setTargetObjectIds(contactIds); 
mail.WhatIds.add(deviceRequest.Id);
		
mail.setTemplateId(emailTemplate.id); 
			
mail.saveAsActivity = false;
Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });

 

I have a custom object called Server which has related list of Accounts (many accounts per server). I am trying to build a list of the accounts from a visual force controller doing something like this:

 

public List<Account> getAccounts() {

if(accounts == null) accounts = [SELECT (SELECT Id FROM Accounts__r) FROM Server__c WHERE Id = server.Id];

return accounts;

}

 

A couple of problems here the first being it doesn't like the server.Id line in the SOQL. The controller has a Server set and there is a value it just doesn't like the syntax I am using. I am wondering if someone could tell me how to put a dynamic value like that in SOQL like this above. 

 

My second issue is I get back an account related list but need to populate that into a list of accounts. Any thoughts on that? The syntax I have doesn't work I get an error saying "Illegal assignment from LIST<Server__c> to LIST<Account>

 

Thanks!

I created a simple inline VF page that does a window.open if there is anything in a custom field called Alerts on our Account Object. It opens another Visual Force page in the window.open which simply displays the important alert for the user.

 

This worked great on the sandbox no issues at all but on production when the window opens it has a bar at the bottom with an 'X' like symbol that says "VisualForce Development Mode Tools" on it. Next to that is a button with the name of the visual force page "AccountAlertPop" and another button next to that with the name of the Apex Controller. If I click on these then the actual source code loads up in the popup window.

 

Why is this showing up and how do I get rid of it? 



We have a Long Text Area custom field on Account called "Account Notes" would like to display that on page layout of Contacts related to that Account but can't figure out how to do so. I attempted to use a forumla field to display it but Long Text Area fields aren't allowed there so I am stuck. Any ideas on how to do this would be much appreciated. 

 

Thank you!