• Ealesie
  • NEWBIE
  • 55 Points
  • Member since 2009
  • Chief Architect
  • BrightGen


  • Chatter
    Feed
  • 2
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 14
    Replies

Hi all,

We have a requirement of using data from 2 custom objects to do some calculations and feed calculated data as a new record into a 3rd object. The operation is to be done once a month and on click of a button or something.

I thought of using Dynamic Apex to create a class having code to calculate the required numbers after fetching records from 2 objects and feed into the 3rd object as new record. Also, to initiate the operation, i would put a custom button on the view page 3rd(calculated object) and on click of it the code (Dynamic apex) should run!

Is my thought process okay? Is it feasible in SFDC using Dynamic APex? Please suggest as i am new to SF development!

Also, i am having problem in attaching the apex class to the custom button! How to make the button run the code on click??

Please suggest! Thanks a lott!!

Not strictly development I know, but......

Does anybody know why the standard Contacts with Accounts report type defaults the Account Billing Address into the Contact Mailing Address when the Contact Mailing Address is blank.  I know this is standard platform behavior when creating a new Contact on an Account via the UI but would not expect a report to do the same.

Any thoughts welcome.
  • September 12, 2015
  • Like
  • 1
I have a Workflow that is settings fields using formula's that reference Custom Settings fields.  UI all works OK.  Apex Tests are causing an internal server error.

If I mark the test SeeAllData=True then, rather than creating the Custom Setting as part of the test data setup then all ok.  Create a new Custom Setting as part of test data markup - Internal Server Error.

Any ideas welcomed.
 

I have a scheduled APEX class that is submitted via Apex using the System.Schedule method.  I am passing a String variable that is dynamically built as the schedule name and I have been randomly receiving an Unhandled Exception caused by: System.UnexpectedException: trigger must be associated with a job detail.

 

I have tried wrapping the calling code in try catch blocks but I am unable to trap this error.

 

After several hours of debugging, trying to replicate the error on demand I have tracked the issue down to the parameter being passed as the Schedule Name ending with a space.

 

Note: ensure you trim leading/ending spaces from Schedule names (and ensure the name does not exceed 60 characters) when submitting  schedule classes

 

I have tried to raise this via Support, but as its APEX generated it is classed as un-suported.  If anyone has come across this issue please let me know if you fixed the issue or just coded around.

 

I am inserting a value into a pickist field via Unit Tests Helper classes (see below) and this field is used by a BI/BU trigger to populate a unique field on the object via concatenation.

 

The issue is that when the unit tests for a class using this object is run in isolation the asserts pass correctly, however, when I run all tests 2 of the test methods using the helpers below fail.  I have tracked this down to the picklist field Lookup_Type__c being set to null somewhere between the insert command executing and the BI/BU trigger running.

 

I have coded around this in the trigger by checking for the picklist containing null and 'null' but I am not happy with this solution as I believe it to be a platform bug.

 

Any suggestions appreciated, also if anyone has succesfully raised a bug with Salesforce that exposed itself via APEX - how did you achieve it.

 

Many thanks

Ealesie

 

Unit Tests Helper methods being used.  This is the only way Transformation__c record are created during Unit Tests.

 

 

public static list<Transformation__c> CreateNewTransformations(String lookupType, Integer recCount)
{
list<Transformation__c> returnList = new list<Transformation__c>();
for (Integer iterator=0; iterator < recCount; iterator++)
{
returnList.add(GetNewTransformation(lookupType, 'LOOKUPVALUE' + iterator, 'RETURNVALUE' + iterator));
}
insert returnList;
return returnList;
}
public static Transformation__c CreateNewTransformation(String lookupType, String lookupValue, String returnValue)
{
Transformation__c newTrans = GetNewTransformation(lookupType, lookupValue, returnValue);
insert newTrans;
return newTrans;
}
public static Transformation__c GetNewTransformation(String lookupType, String lookupValue, String returnValue)
{
return new Transformation__c(Lookup_Type__c = lookupType,
Lookup_Value__c = lookupValue,
Return_Value__c = returnValue,
Lookup_Key__c = lookupType + lookupValue);
}

public static list<Transformation__c> CreateNewTransformations(String lookupType, Integer recCount) { list<Transformation__c> returnList = new list<Transformation__c>(); for (Integer iterator=0; iterator < recCount; iterator++) { returnList.add(GetNewTransformation(lookupType, 'LOOKUPVALUE' + iterator, 'RETURNVALUE' + iterator)); } insert returnList; return returnList; }
public static Transformation__c CreateNewTransformation(String lookupType, String lookupValue, String returnValue) { Transformation__c newTrans = GetNewTransformation(lookupType, lookupValue, returnValue); insert newTrans; return newTrans; }
public static Transformation__c GetNewTransformation(String lookupType, String lookupValue, String returnValue) { return new Transformation__c(Lookup_Type__c = lookupType, Lookup_Value__c = lookupValue, Return_Value__c = returnValue, Lookup_Key__c = lookupType + lookupValue); }

 

Not strictly development I know, but......

Does anybody know why the standard Contacts with Accounts report type defaults the Account Billing Address into the Contact Mailing Address when the Contact Mailing Address is blank.  I know this is standard platform behavior when creating a new Contact on an Account via the UI but would not expect a report to do the same.

Any thoughts welcome.
  • September 12, 2015
  • Like
  • 1
I have a Workflow that is settings fields using formula's that reference Custom Settings fields.  UI all works OK.  Apex Tests are causing an internal server error.

If I mark the test SeeAllData=True then, rather than creating the Custom Setting as part of the test data setup then all ok.  Create a new Custom Setting as part of test data markup - Internal Server Error.

Any ideas welcomed.
 
I have a Workflow that is settings fields using formula's that reference Custom Settings fields.  UI all works OK.  Apex Tests are causing an internal server error.

If I mark the test SeeAllData=True then, rather than creating the Custom Setting as part of the test data setup then all ok.  Create a new Custom Setting as part of test data markup - Internal Server Error.

Any ideas welcomed.
 
Hi, I have some code that creates Community Users using SIte.CreatePortalUser().  I create a contact or find an existing contact, and the User selects an Account (for a Drop Down List).  When I run Site.CreatePortalUser(user, accountId, password) usually it works, but sometimes it returns NULL.  

I have tried troubleshooting why it return NULL, but cannot find anything.  I am using forceSSL=true on the VF page, I ensure the Username (email) does not already exist in the User table, I've ensure the Account is owned by someone with a Role, I've ensure that if I find an existing contact it is not already associated to a Community User, and all required fields on the User are filled.  

Am I missing anything else?

Also, I read somewhere that if Site.CreatePortalUser() does not work, it is suppose to send an email to the Site Administrator.  I have yet to see that email.

Any suggestions would be greatly appreciated.

 

Can anyone help me build a formula for a workflow field update? 

 

I have a field called Contract Expire Date and we have to send out a Renewal Notification a certian amount of days before this date.  I have a field called Renewal Notification Terms and my users will populate this as we get signed agreements based on the term days for example 90 days.

 

I need a formula that will take the Contract Expiration date and subtract the number of days indicated in the Renewal Notification field and populate the field called Communication Date.

 

For instance if the Expire date is 11/28/2011 and the Renewal Notification is 60 days i need the Communication Date to read 9/26/2011.

We have Integrated Salesforce with .Net App. Its like, Sending the data from Salesforce to .Net.

When the field mapping is done, It should be in the Salesforce User hands that, whether the data should sent from Salesforce to .Net or not Eg :(creating a button "Send Data")

Now, These fields are on differnt objects. How can this be done?

 

a)Could i create a Apex code which captures all these data and sends to the .NET app? I dint consume their Web Services yet. Do i have to?

 

b) Is there any other way? By creating a Checkbox or a Picklist value? So that the data from those fields and that particular record will appear in the .Net app.?

 

Please giv me the Best Possible Suggest. Could be a good option if there wouldnt be any coding involved from the Salesforce side. Because our Developer is on Contract till next week,




Thank you.


  • August 30, 2011
  • Like
  • 0

Hi,

 

I wish to instantiate a webservice call after I insert data into an object. I wondered how do I retrieve and pass a full object from within  a trigger to my webservice method call.

 

I had thought I could do something like this.

 

trigger MyObjDataAfterInsert on MyObjData__c (after insert) { 

  ProcessingService.processObjData(Trigger);

}

 

Where  "ProcessingService" is my webservice name (I changed the name for this forum)

However it does not compile ok.

 

How do i enter the pass my object within the   ProcessingService.processObjData(Trigger) method?

The Trigger.new method returns a list but I don't think this is what I need. I need to pass the full object within my method call.

 

Thanks!

I have a scheduled APEX class that is submitted via Apex using the System.Schedule method.  I am passing a String variable that is dynamically built as the schedule name and I have been randomly receiving an Unhandled Exception caused by: System.UnexpectedException: trigger must be associated with a job detail.

 

I have tried wrapping the calling code in try catch blocks but I am unable to trap this error.

 

After several hours of debugging, trying to replicate the error on demand I have tracked the issue down to the parameter being passed as the Schedule Name ending with a space.

 

Note: ensure you trim leading/ending spaces from Schedule names (and ensure the name does not exceed 60 characters) when submitting  schedule classes

 

Hello Apex Wizards (-: I

 

I have an annoying problem.

 

In our system we have an object called “Dongles” and this object has a reference field(Lookup Relationship) to the account object named customer_c.

 

I have a case on dongle save where I need to take a value from the account related to it and put it in the dongle record.

 

I am assuming it’s possible to get the data of the account(that is related to the dongle) without doing an extra query (As we know, apex is very cheap on queries :smileyvery-happy:) but when I try to get a pointer to the account object using the syntax below I get a null object.

 

Account AccountPointer = dongleToSync.Customer__r;

 

Anyway, I figure there is a way to get over this hump without making an extra query. But I could be wrong )-:

 

Any help will be greatly appreciated….

Hello,

 

I'm trying to hack my way around making the Quote Name auto-populate with a custom number field

 

Below is the trigger that does not work, I was only able to add a specific value into the Quote Name field. 

 

I need the trigger to put the value of the custom quote auto-number field Quote_Number__c.

 

Any ideas? Thanks!

 

 

trigger QuoteTrigger on Quote (before insert) {
 

for(Quote q : Trigger.new) {

q.Name = q.Quote_Number__c;

}

}

Hi all,

We have a requirement of using data from 2 custom objects to do some calculations and feed calculated data as a new record into a 3rd object. The operation is to be done once a month and on click of a button or something.

I thought of using Dynamic Apex to create a class having code to calculate the required numbers after fetching records from 2 objects and feed into the 3rd object as new record. Also, to initiate the operation, i would put a custom button on the view page 3rd(calculated object) and on click of it the code (Dynamic apex) should run!

Is my thought process okay? Is it feasible in SFDC using Dynamic APex? Please suggest as i am new to SF development!

Also, i am having problem in attaching the apex class to the custom button! How to make the button run the code on click??

Please suggest! Thanks a lott!!

Hi I have wrote the following trigger and the exception is throwing in the assignment of values:

 

 

CampaignProductPopulationTrigger on Campaign (after delete, after insert, after update) {
if(Trigger.isAfter){

if(Trigger.isUpdate){
Set<Id> campaignIds = new Set<Id>();
Set<Id> productIds = new Set<Id>();
Set<String> productSet = new Set<String>();
String productNames =

null;
for(Campaign campaign:Trigger.new){
campaignIds.add(campaign.id);

}

for(Campaign_Product__c campro:[Select Product__r.id from Campaign_Product__c where Campaign__r.id IN:campaignIds])
productIds.add(campro.Product__r.id);

for(Product2 proVal:[Select Name from Product2 where id IN:productIds])
productSet.add(proVal.

Name);
for(String setVal:productSet)
productNames+=setVal+

', ';
productNames=productNames.substring(0,productNames.length()-2);

for(Campaign campaign:Trigger.new)
campaign.Campaign_Products__c = productNames;//ERROR LINE

}


}

}

 Please tell me how to get rid of this error

 

Hello.

 

Im new at Apex and im having this problem.

 

I need to get an list of an object populated with Apex Data Loader and now im trying to get some fields and save into another object.

 

Something like it

 

 

public void createClienteCustom(){	
		List<Carga_Inicial__c> cargaInicial = [Select c.uf__c, c.municipio__c,	
							c.dataCadastro__c, 
							c.cnpjCpf__c, 
							c.cliente__c, 
							c.campoLivre__c, 
						        c.campoLivreAlt__c 
							From Carga_Inicial__c c];
		
	
		Cliente__c cli = new Cliente__c();
		for(Carga_Inicial__c carga: cargaInicial){
				cli.cnpjCpf__c = carga.cnpjCpf__c,
				cli.cliente__c = carga.cliente__c,
				cli.campoLivre__c = carga.campoLivre__c,
				cli.campoLivreAlt__c = carga.campoLivreAlt__c,
				cli.dataCadastro__c = carga.dataCadastro__c,
				cli.municipio__c = carga.municipio__c,
				cli.uf__c = carga.uf__c
			
			insert cli;	
		}
	}

 

 

Im getting the following message
System.DmlException: Insert failed. First exception on row 0 with id a0AA0000002tPi0MAE; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

 

 

What can i do to solve it?

 

Tks for all community

Hi All

 

I am preparing a Visualforce page which is having a dependent picklist i.e Picklist A (Controlling picklist) and Picklist B (Dependent picklist). There is one more textarea field which is supposed to be rendered/visible only when there is a specific value in dependent picklist i.e picklist B.

 

I am facing the problem in rendering the textarea field.

Extension:

 

 

public boolean check;
public boolean isCustom{
        get{
            check=false;
            if(dependent picklist val == 'specific_val')
            {
                check = true;
                system.debug('check-------->'+check);
            }   
            else
            {
                check=false;
            }
            return check ;
           }
           set;
        
    }

 

Visualforce page:

 

<apex:pageBlockSectionItem >
<apex:outputLabel > dependent picklist </apex:outputLabel>
<apex:inputField value="{!dependentpicklist}" id="etype" >
<apex:actionSupport event="onchange" reRender="cust, atp"/>
</apex:inputField>
</apex:pageBlockSectionItem>    
<apex:pageBlockSectionItem >
<apex:pageBlockSectionItem id="cust" rendered="{!isCustom}" >
<apex:outputLabel > Custom textarea </apex:outputLabel>
<apex:inputField value="{!textarea}" id="atp"/>
</apex:pageBlockSectionItem>

 

 

 

I am unable to find where the error is.

I checked in debug logs that when its a specific value in the picklist then boolean value check is getting true but in rendered its not working.

I just installed the super follow button. The package installed in salesforce, but I cannot view the buttons that are supposed to be available. Can anyone offer help on this? Is there something else that needs to be done to make this app visible?