• mauro_offermann
  • NEWBIE
  • 80 Points
  • Member since 2013
  • CTO at GOCODE Ltda.
  • GOCODE Ltda.

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 27
    Replies

hi all 

is it possible to query custom settings data thru soql....

 

thanks

Hi all,

 

I was learning new things from an apex_workbook and on exception chapter when I tried to create custom exception I was using two classes in one file(book example)

 

Because I am new in all this, I couldn't determine how to handle an error in this (Save error: unexpected token: public) code

 

Error occures in 3. row: it underlines reserved word 'public' ...

 

public class MerchandiseException extends Exception{}

public class MerchandiseUtility{
	
	public static void mainProcessing(){
		try{
			insertMerchandise();
		}catch(MerchandiseException me) {
			System.debug('Message: ' + me.getMessage());
			System.debug('Cause: ' + me.getCause());
			System.debug('Line number: ' + me.getLinenumber());
			System.debug('Stack trace : ' = me.getStackTraceString());
		}
	}
	
	public static void InsertMerchandise(){
		try{
			Merchandise__c m = new Merchandise__c();
			insert m;
		}catch(DMLException e){
			throw new MerchandiseException('Merchandise item could not be inserted ' + e)
		}
	}
	
}

 

Thanks in advance.

  • November 16, 2013
  • Like
  • 0

global class LDPurchasedSV implements Database.Batchable<sObject>, Database.AllowsCallouts {
global Database.QueryLocator start(Database.BatchableContext BC) {
String query = 'SELECT Name,SV_Synced_Hidden__c,Lead_Number_Hidden__c,SV_Priority_Hidden__c,OwnerId,Days_To_SV_Hidden__c, Id FROM Lead WHERE Days_To_SV_Hidden__c <= 3 and SV_Synced_Hidden__c = FALSE';
return Database.getQueryLocator(query);
}


global void execute(Database.BatchableContext BC, List<Lead> scope) {

integer i=1;

for (Lead e : scope) {
if(e.OwnerId == '00Gi0000000iqle')
{

if(e.Days_To_SV_Hidden__c ==0)
{
e.SV_Priority_Hidden__c =1;
}
else{
if(e.Days_To_SV_Hidden__c == 1)
{
e.SV_Priority_Hidden__c =2;
}
else
{
e.SV_Priority_Hidden__c =3;
}
}
e.SV_Synced_Hidden__c = TRUE;
e.OwnerId ='00Gf0000000TIWj';
}
e.Lead_Number_Hidden__c = i;
i++;
Update scope;
}
}
global void finish(Database.BatchableContext BC) { }
}

 

 

I am trying to add a number field for all the records that come through this batch. The number should increment with every record.

Lead_Number_Hidden__c should be updated with number.

The above code is giving the same number for all the records.

 

I created an unmanaged package on  my developer org.

1º I had created a FieldSet on Account Called "AccountFilters" and  added some fields like  "AccountSource".
2º I have the following methods:

public Schema.FieldSet getFieldSet(String fieldSetName) {
  Schema.Describesobjectresult result = Account.getSobjectType().getDescribe();
  Map<String, Schema.FieldSet>  fieldSetMap = result.fieldSets.getMap();
  System.assert(fieldSetMap.size() > 0, 'No hay conjuntos para esta clase');
  Schema.FieldSet fs = fieldSetMap.get(fieldSetName);
  System.assert(fieldSetMap.containsKey(fieldSetName), 'No se encontró el conjunto ' + fieldSetName);
  return fs;
}


public Schema.FieldSetMember[] getFields(String fieldSetName) {
  return getFieldSet(fieldSetName).getFields();
}

The method getFieldSet('AccountFilters') works fine and return the expected fieldset, but the method getFields('AccountFilters') returns an empty FieldSetMember[] array. Why?

I would like to deploy from sandbox to production without force.com ide.

Where is outbound change set option currently?

Maybe it was moved elsewhere?

I have a single Map that works as  custom object cache for all organization.


I can't use custom settings because this is a legacy system and all data is stored in a custom object.
I tried to declare the Map as static but all users rebuild the object in each request.

Any suggestions?

I enabled Salesforce CRM Contents on my org.

I need to associate 17000 different documents with its accounts.

I upload successfully 17000 documents via dataloader to ContentDocument object but they are not associated as related content to accounts. How can I do that?

Hi,

I'm trying to import my HTTPS certificate into Salesforce and once I click 'save' after uploading my JKS and keystore password, I just see the below. error though I'm an admin user with the 'Manage certificates' permission set in my profile page.

Data Not Available
The data you were trying to access could not be found. It may be due to another user deleting the data or a system error. If you know the data is not deleted but cannot access it, please look at our support page. 


Can anyone suggest me how to fix this?
I created an unmanaged package on  my developer org.

1º I had created a FieldSet on Account Called "AccountFilters" and  added some fields like  "AccountSource".
2º I have the following methods:

public Schema.FieldSet getFieldSet(String fieldSetName) {
  Schema.Describesobjectresult result = Account.getSobjectType().getDescribe();
  Map<String, Schema.FieldSet>  fieldSetMap = result.fieldSets.getMap();
  System.assert(fieldSetMap.size() > 0, 'No hay conjuntos para esta clase');
  Schema.FieldSet fs = fieldSetMap.get(fieldSetName);
  System.assert(fieldSetMap.containsKey(fieldSetName), 'No se encontró el conjunto ' + fieldSetName);
  return fs;
}


public Schema.FieldSetMember[] getFields(String fieldSetName) {
  return getFieldSet(fieldSetName).getFields();
}

The method getFieldSet('AccountFilters') works fine and return the expected fieldset, but the method getFields('AccountFilters') returns an empty FieldSetMember[] array. Why?
this is my apex class:
public with sharing class TerminalsCX {

    public TerminalsCX(ApexPages.StandardController controller) {}
  
    public List<Terminal__c> getTerminals() {
        try {
            return[Select Name, Location__c from Terminal__c ORDER BY Name ASC];
        } catch(Exception e) { apexPages.addMessages(e); } return null;
    }
}

and this is the test class:
@isTest
public class TerminalsCX_Test {

    @isTest(SeeAllData=true)
    public static void TerminalsCX() {
        Terminal__c terminal = new Terminal__c(Name='Terminal Test');
        insert terminal;
       
        Test.startTest();
            TerminalsCX controller = new TerminalsCX(new ApexPages.StandardController(terminal));
            controller.getTerminals();
        Test.stopTest();
    }
}

when i run the test the whole line of "} catch(Exception e) { apexPages.addMessages(e); } return null;" is not included, so this is just 80%, how can i make it 100%? how can i include catch in the test class?
  • January 12, 2014
  • Like
  • 0

I would like to deploy from sandbox to production without force.com ide.

Where is outbound change set option currently?

Maybe it was moved elsewhere?

I have a single Map that works as  custom object cache for all organization.


I can't use custom settings because this is a legacy system and all data is stored in a custom object.
I tried to declare the Map as static but all users rebuild the object in each request.

Any suggestions?

I am brand new to Apex, so please forgive the basic question, but I am getting the following error from this Apex class: Compile Error: expecting right curly bracket, found 'insert' at line 3

 

public class CloneClassAttendance {

Campaign NewCamp = new Campaign(Name = 'Test Campaign record');

insert NewCamp;

 

Campaign NewCamp = [SELECT Type FROM Campaign WHERE Name = 'Test Campaign record'];

NewCamp.Type = 'Class Attendance';

update NewCamp;

}

 

Any help would be much appreciated.

Thanks, Michele

System.CalloutException: Web service callout failed: Failed to deserialize value '8/24/2011', due to:Unable to parse date

 

Pls help. Its very urgent

hi all 

is it possible to query custom settings data thru soql....

 

thanks

Hi all,

 

I was learning new things from an apex_workbook and on exception chapter when I tried to create custom exception I was using two classes in one file(book example)

 

Because I am new in all this, I couldn't determine how to handle an error in this (Save error: unexpected token: public) code

 

Error occures in 3. row: it underlines reserved word 'public' ...

 

public class MerchandiseException extends Exception{}

public class MerchandiseUtility{
	
	public static void mainProcessing(){
		try{
			insertMerchandise();
		}catch(MerchandiseException me) {
			System.debug('Message: ' + me.getMessage());
			System.debug('Cause: ' + me.getCause());
			System.debug('Line number: ' + me.getLinenumber());
			System.debug('Stack trace : ' = me.getStackTraceString());
		}
	}
	
	public static void InsertMerchandise(){
		try{
			Merchandise__c m = new Merchandise__c();
			insert m;
		}catch(DMLException e){
			throw new MerchandiseException('Merchandise item could not be inserted ' + e)
		}
	}
	
}

 

Thanks in advance.

  • November 16, 2013
  • Like
  • 0

I have some additional fields on my VisualForce page that are not part of the Case Object.  I don't know how to add those validation errors to the system generated validation errors (AccountID, ContactID, etc) that I display on the page. 

 

I use the following:

 ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Asset:  You must enter a value'));

HOWEVER this only appears AFTER I have resolved all the system validations errors.  I don't want them to have to click 2x if they have errors.

 

I also tried ===immediate="true"=== on the button that I have.

HOWEVER then I don't see any of the object data(AccountID, ContactID, etc).

 

Any idea what to do?

 

  • November 16, 2013
  • Like
  • 0

Hi ,

 

Can any once face this problem when we executin some code using developer console the log will not open.

 

Any one face this problem.

 

Thank you

  • November 15, 2013
  • Like
  • 0

Hi , I am geeting below error ocationally , but it runs good most of the time. any help will be appricated.

 

 

 

 

 
public with sharing class Alert {  
	
	@future
	public static void processCustomAccounts(list<String> names, Map<String,String> alert) {
		
          
          // list to store the custom accounts to update
          List<CustomAccount__c> customaccountsToUpdate = new List<CustomAccount__c>();
            
          // iterate through the list of custom accounts to process
          for (CustomAccount__c a : [Select Id, Name,Alert__c From CustomAccount__c where Name like :names]) {
               string [] truncateagain = a.Name.split('-'); 
               string tpart1 = truncateagain.get(0);
               string tpart2 = truncateagain.get(1);
               string addfirsttwoparts = tpart1 + '-' + tPart2 + '%';
               
               // if alert value in the map passed in the method above is not null
			   // replace all existing custom accounts with this new value.
			   if(alert.values()!=null){
                             	a.Alert__c = alert.get(addfirsttwoparts);
               } 
			   // if alert value in the map passed in the method above is null
			   // make this null value as the value of the 1st record found in the SOQL			   
			   else if(alert.values()==null){
               	
               	id myalert = a[0].Alert__c;   // error: expression must be a list type: SOBJECT:CustomAccount__c               	a.Alert__c = myalert;
               	system.debug('now what!!!!!!!');
               	
               	
               	}
               // add the custom accounts to the list to update
               customaccountsToUpdate.add(a);
          }
          
                   AlertProcessorControl.inFutureContext = true;
                    
          if(!customaccountsToUpdate.isEmpty()){
          	update customaccountsToUpdate;
          }
    }
}

 

  • November 14, 2013
  • Like
  • 0

The eblow code does not display the data. What could be the problem?

 

VF Page

 

<apex:page standardController="opportunity" extensions="wbsextension">
<apex:form >
<apex:pageBlock title="WBS Element">

<apex:pageBlockSection title="WBS Element Details" columns="3">

<apex:pageBlockTable value="{!obj1}" var="a" cellpadding="10" rules="all" styleclass="pageblock" >>
<apex:column value="{!a.pse__Opportunity__r.Opportunity_Number__c}"/>
<apex:column value="{!a.pse__Project_Manager__c}"/>
<apex:column value="{!a.pse__Start_Date__c}"/>

</apex:pageBlockTable>
</apex:pageBlocksection>


<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Extension:

 

public class wbsextension {

public wbsextension(ApexPages.StandardController controller) {


}


public pse__Proj__c[] getobj1(){

 

return [SELECT pse__Opportunity__r.id,pse__Opportunity__r.Opportunity_Number__c,pse__Project_Manager__c,pse__Start_Date__c FROM pse__Proj__c WHERE pse__Opportunity__r.id='vp006c0000008iP'];

 

}
}

global class LDPurchasedSV implements Database.Batchable<sObject>, Database.AllowsCallouts {
global Database.QueryLocator start(Database.BatchableContext BC) {
String query = 'SELECT Name,SV_Synced_Hidden__c,Lead_Number_Hidden__c,SV_Priority_Hidden__c,OwnerId,Days_To_SV_Hidden__c, Id FROM Lead WHERE Days_To_SV_Hidden__c <= 3 and SV_Synced_Hidden__c = FALSE';
return Database.getQueryLocator(query);
}


global void execute(Database.BatchableContext BC, List<Lead> scope) {

integer i=1;

for (Lead e : scope) {
if(e.OwnerId == '00Gi0000000iqle')
{

if(e.Days_To_SV_Hidden__c ==0)
{
e.SV_Priority_Hidden__c =1;
}
else{
if(e.Days_To_SV_Hidden__c == 1)
{
e.SV_Priority_Hidden__c =2;
}
else
{
e.SV_Priority_Hidden__c =3;
}
}
e.SV_Synced_Hidden__c = TRUE;
e.OwnerId ='00Gf0000000TIWj';
}
e.Lead_Number_Hidden__c = i;
i++;
Update scope;
}
}
global void finish(Database.BatchableContext BC) { }
}

 

 

I am trying to add a number field for all the records that come through this batch. The number should increment with every record.

Lead_Number_Hidden__c should be updated with number.

The above code is giving the same number for all the records.

 

Hi,

 

I got to write a trigger for the following requirement:

 

There are 2 custom objects. Service Agreement object and Equipment object.

 Once the equipment has been moved off the service agreement, the ‘Under Contract’ picklist should be defaulted to unchecked and ‘Contract Status’ should changed to ‘Not Under Contract’.

 

 

  • November 14, 2013
  • Like
  • 0

Hi

 when i save the test class IN SFDC.i got error name:java.lang.reflect.InvocationTargetException . already i file the case..how to overcome thi issue. please help me.

  • November 09, 2013
  • Like
  • 0