• myforcedotcom
  • NEWBIE
  • 110 Points
  • Member since 2011
  • Solutions Architect
  • Trifecta Technologies


  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 26
    Replies

Greetings,

 

Need help with logic--

 

I have a work flow rule that stamps a "Date submitted" field when a record enters the approval process.  I want to fire a trigger to send an email to a specified user 4 hours after the date submitted field is stamped with the current date/time.  With that said, I looked into an asynchronous trigger to send the email but I don't think this is the best option since I cannot control the time the trigger fires.  Does anyone have a recommendation on how I can achieve this?

 

Thanks in advance!

 

Hi,

 

 

I have created custom object Task__c. It has fields like TaskName, Due Date, Status.

 

I want to display these tasks on calendar according to their due dates.

 

Can i make this functionality using standard salesforce calendar? If yes then How?

 

Do i need to use custom calendar component? Is it possible to display this custom calendar component on homepage?

 

 

Thanks and Regards,

Devendra S

 

The below trigger works great when it is managing on record at a time, but the trigger will return this error when more than one record is processed at the time. I thought the code was ulkified. What more needs to be done. Here is the trigger.

 

trigger cmOwner on CampaignMember (Before Insert, Before Update) {

    Set<Id> lIds = new Set<Id>();
    Set<Id> cIds = new Set<Id>();
    
    for(CampaignMember cm : Trigger.new) {
    System.debug('**** 1 lIds leadid: '+cm.leadid);
    System.debug('**** 1.5 cIds contactid : '+cm.contactid);

        LIds.add(cm.leadid);
        cids.add(cm.contactid);


    System.debug('**** 2 lIds leadid : '+cm.leadid);
    System.debug('**** 2.5 cIds contactid : '+cm.contactid);
    
   }
   String l;
   String user;
   String sUser;

   sUser = [select id from user where Name = 'Shayla Wentz'].id;
   List<contact> contact = [select ownerid from contact where id in:cIds];
   List<Lead> ow = [select ownerid from lead where id=:lids];

  System.debug('**** 2.5 ow : '+ow);

    List<user> leadowner = [select id from user where id =: ow[0].ownerid];
    
    System.debug('**** 3 leadowner : '+leadowner);
    
    for(CampaignMember c: trigger.new){
      If(leadowner != null){
        c.OwnerName__c = leadowner[0].id;
        System.debug('****************************aa 3 c.lead.ownerid : '+c.lead.ownerid);
        }  else{
        
        c.OwnerName__c = sUser;
        }
        
    if(c.contactid <> null){
        c.OwnerName__c = contact[0].ownerid;
        }
    }  
}

 

Thank you,

ckellie

Is it possible to re-sort records that are selected on a list view and displayed on another page?  For example, I select 3 accounts from a listview, which are then displayed on a Mass Edit page.  I have tried several method to (in a controller extension) to re-sort the records without any luck.  Is there a way of using getRecords, sorting the records, then using setRecords to update the page display? Any ideas?

 

Thanks,

Barb R.

  • March 11, 2011
  • Like
  • 0
I am getting the following error on my external objects after deploying them using the Force.com ANT Migration Tool.

__MISSING LABEL__ PropertyFile - val DataSourceDataTypeNotSupported not found in section ApexConnectorErrors

This error appears in the related list where the External Object is the related list. This only appears to happening on either Currency Fields and Date Fields.

If I delete the Currency and Date fields on the deployed external object, and recreate them declaritively the error goes away.
There appears to be an issue with the deployment using the ant migration tool and the metadata.

Can anyone help with this issue.

I have a Chatter FeedItem Trigger that fires when a user posts a comment on an Opportunity but does not fire when a tracked field on and opportunity is changed and posts to the Feed. shouldn't the FeedItem trigger fire for every post whether it came from a user comment or a field change?

 

 

I have a vf page that I am trying to display the mini page when I hover over the link. Below is my vf page link statement.

 

When I hover over the link I get a hover window but it is the mini page for the control but it has the sidebar and menu displayed. Also when i move off the link the page does not hide.

 

<a href="/{v.aid}" id="{!v.aid}{!day.DayName}{!day.dayofmonth}"                                           onblur="LookupHoverDetail.getHover('{!v.aid}{!day.DayName}{!day.dayofmonth}').hide();"                                           onmouseout="LookupHoverDetail.getHover('{!v.aid}{!day.DayName}{!day.dayofmonth}').hide();"                                           onfocus="LookupHoverDetail.getHover('{!v.aid}{!day.DayName}{!day.dayofmonth}','/{!v.aid}/m?retURL=%2Fapex%2FMilestone1_Calendar_Team&amp;isAjaxRequest=1&amp;nocache=1308340279175;').show();"         onmouseover="LookupHoverDetail.getHover('{!v.aid}{!day.DayName}{!day.dayofmonth}','/{!v.aid}/m?retURL=%2Fapex%2FMilestone1_Calendar_Team&amp;isAjaxRequest=1&amp;nocache=1308340279175;').show();">{!v.name}</a>

 

any help is a big thanks.

When you create a new trigger using the Force.com IDE, you get a file that looks like this:

 

trigger AccountTrigger on Account (after insert, after update) {

}

 

Is there a way to modify the template that is used to generate a trigger so when I create the trigger it would look like:

 

trigger AccountTrigger on Account (after insert, after update, before insert, before update) {

if(trigger.isInsert && trigger.isAfter){

//implement code

}

 

  if(trigger.isUpdate && trigger.isAfter){

   //implement code

  }

}

 

 

I am modifying the field attributes of a custom field using Eclipse.

On of the types available is EncryptedText.

When I save the object I get and Invalid data type error. Here are the attributes for the field type:

 

 

<fields>
        <fullName>XXXPassword__c</fullName>
        <externalId>false</externalId>
        <label>XXXPassword</label>
        <length>25</length>
        <required>false</required>
        <trackFeedHistory>false</trackFeedHistory>
        <unique>false</unique>
        <type>EncryptedText</type>
        <maskChar>asterisk</maskChar>
        <maskType>all</maskType>
    </fields>

 

 

 

thanks in advance for your help with this

Is there a way to determine if a trigger on a Contact was caused by someone clicking the Save button on a page, or if an insert / update came from an API call from an app like Outlook?

 

 

thanks for your help.

Greetings,

 

Need help with logic--

 

I have a work flow rule that stamps a "Date submitted" field when a record enters the approval process.  I want to fire a trigger to send an email to a specified user 4 hours after the date submitted field is stamped with the current date/time.  With that said, I looked into an asynchronous trigger to send the email but I don't think this is the best option since I cannot control the time the trigger fires.  Does anyone have a recommendation on how I can achieve this?

 

Thanks in advance!

I'm having trouble figuring out how to write test code for the following classes. They all seem very simple, but I'm a complete rookie to test code and am at a loss. I don't know if this will make sense to anybody but I wanted to see if I could get some help on these two classes :

 

 

 

 

public with sharing class Milestone1_TestProjectBuilder {

    public Integer numberMilestones { get; set; }
    public Integer numberTasks {get; set; }
    
    public void buildProject() {
        
        Milestone1_Project__c newProject = Milestone1_Test_Utility.sampleProjectActive('Sample ' + Datetime.now());
        insert newProject;
        
        for (Integer i=0; i < numberMilestones; i++) {
            Milestone1_Milestone__c ms = Milestone1_Test_Utility.sampleMilestone(newProject);
            insert ms;
            for (Integer j=0; j < numberTasks; j++) {
                Milestone1_Task__c task = Milestone1_Test_Utility.sampleTask(ms);
                insert task;
                
            }
        }
        
    }
}

 

 

and this one which are essentially just a field validation messages :

 

public with sharing class Milestone1_Move_Exception extends Exception{
    
    public static final String ERROR_MILESTONE_ALREADY_ASSIGNED_PROJECT = 'A milestone you are attempting to move is already assigned to this project. Please review your selection and try again.';
    public static final String ERROR_TASK_ALREADY_ASSIGNED_MILESTONE = 'A task you are attempting to move is already assigned to this milestone. Please review your selection and try again.';
    public static final String ERROR_MILESTONE_COMPLETE = 'Milestone is Complete, the Task can not be moved';
    public static final String ERROR_MILESTONE_HAS_SUCCESSORS = 'Top Level Milestone has successors and cannot be moved.  Redirect those successors and try again.';
    public static final String ERROR_MILESTONE_HAS_PREDECESSOR = 'Top Level Milestone has predecessor and cannot be moved.  Remove that predecessor and try again.';
    
    static testMethod void testConstants() 
    {
        //Just a place holder test method for static constants on this exception class.
        system.assert(true);
    }

}

 

 

As I'm sure you can tell, I'm a complete rookie to test code. I apologize for asking for help on this and not being able to at least give some. Thank you very much for your help and time.

  • October 01, 2013
  • Like
  • 0

Hi all - I've got a custom object for which there are two basic kinds of records, parents and children. There is a same-object Lookup field on that object that looks up to the object called Object_Self_Lookup__c. I want to use this to relate the children to the parents. 

 

The object also has an external Id called External_Id_Field__c.

 

I'm generating large batches of these records in a scheduled Apex class, and maintaining two different lists, one of parents, one of children. Each record, no matter the type, is assigned a unique value to External_Id_Field__c.

 

My goal is that I can insert the list of Parent records first, having set all their external ids, and then insert the list of children, and have the lookup to the parent record resolved by way of the external Id. I've like to avoid adding a trigger, or making a second pass to get the reference set if it's possible.

 

Is this possible? If so, what am I doing wrong here? This is simplified version of my full code, but this doesn't work either.

 

Thanks!

 

List<Custom_Object__c> parentList = new List<Custom_Object__c>();
List<Custom_Object__c> childList = new List<Custom_Object__c>();

Custom_Object__c objOne = new Custom_Object__c();
objOne.External_Id_Field__c = '1234';
parentList.add(objOne);

Custom_Object__c objTwo = new Custom_Object__c();
objTwo.Object_Self_Lookup__r = objOne;
childList.add(objTwo);

insert parentList;
insert childList;

 

When I try to call PageReference.getContent() from a trigger, I get the following error.

 

Getting content from within triggers is currently not supported.

 

Do anyone have a solution for this?

  • September 21, 2011
  • Like
  • 0

 

Hi,

 

 

I have created custom object Task__c. It has fields like TaskName, Due Date, Status.

 

I want to display these tasks on calendar according to their due dates.

 

Can i make this functionality using standard salesforce calendar? If yes then How?

 

Do i need to use custom calendar component? Is it possible to display this custom calendar component on homepage?

 

 

Thanks and Regards,

Devendra S

 

Hello everyone,

 

I developed a code to integrate Salesforce x Sharepoint. 
I need to event that be call when a Item is changed. 

 

Does the salesforce have something to help me?


Sales 

Hi,

I had a nother post but I think I may have had to much dialog and lost causing it to lose the intent.

 

The following vf page snippet allows me to click on the magnify glass and select an active user from a dialog box list.  Once the user is selected they show up in the field.  Now when I click the button I want to be able to access that value (user id or name) within apex so that I can do what I need to do.  I am not sure how to get to the value in the field?  Preferable I would want to get to the user id in the code but what shows on the vf page is the user name which is what the user needs to see.

 

            <apex:pageBlockSectionItem >             
                <apex:outputLabel value="New Owner" for="theNewContactOwnerLookup"/>
                <apex:inputField id="theNewContactOwnerLookup" value="{!NewContactOwner.OwnerId}"/>
              </apex:pageBlockSectionItem>                        
            </apex:pageBlockSection>
            <apex:pageblockButtons >
                <apex:commandButton value="Change Owner" action="{!changeOwner}"/> 
            </apex:pageblockButtons>                      
        </apex:pageBlock>

 

Hi Everyone.

 

I've built a page to allow users to select a Case Record Type from a favourites list or all Case Record Types.  It works well except the All Case Types list shows all the Case Record Types in our org rather than those normally accessible to the current user.

 

My question: how can I access the list of Case Record Types available to the user from their Profile in my controller?

 

Thanks in advance,

James.



  • August 17, 2011
  • Like
  • 0

Hi


I'm piloting an app I wrote.

I've written a Batch Apex that processes by records and for each performs some logic including sending one HTTP request and one database.insert() operation.

 

I set my batch size to 1 since the limit on callouts within a batch operation is 1.


Problem is that I'm still getting an exception: System.LimitException: testtt:Too many callouts: 1

 

This is my code:

 

	
...	

if(doBatch){
	MicroCampaignBatchPublish batch = new MicroCampaignBatchPublish(GW.Name, template.From_Number__c, 
									campaign.Greeting__c, campaign.SMS_Text__c, 
									campaign.Id, campaign.Campaign_num__c, 
									template.Id);		

	String queryAll = 'SELECT ID, Name, Member_Num__c, Contact__c, Contact__r.FirstName, Contact__r.MobilePhone FROM Micro_Campaign_Member__c WHERE   Contact__r.DoNotCall = false AND Active__c = true AND Micro_Campaign__c = \'' + campaignId + '\'';

	batch.query = queryAll;      		

	ID batchId = Database.executeBatch(batch, 1);
}

 

and then:

 

global void execute(Database.BatchableContext BC, List<Micro_Campaign_Member__c> scope){
					   				
			
for(Micro_Campaign_Member__c member :scope){
			
		...

		SMSBody = myGreeting + ' ' + member.Contact__r.FirstName +', ' + SMSBody;

		try{				
			//This is where the callout happens
                        sms = sender.sendASingleSMS(member.Contact__r.MobilePhone, member.Contact__r.FirstName, SMSBody);
		}
		catch(Exception e){
		   	system.debug(Logginglevel.DEBUG, 'problem sending SMS: ' + e.getTypeName());			
		   	system.debug(Logginglevel.DEBUG, 'problem sending SMS: ' + e.getMessage());			
		   	system.debug(Logginglevel.DEBUG, 'problem sending SMS: ' + e.getCause());			
		}			
				
		//sentSMSs.add(sms); 
		MicroCampaignAPI.insertSMSs(new List<SMS__c> {sms});				
	...
		   										
	}			
    }

 


Does anyone knows what is the problem?

I need to release this app ASAP - Please help.


Many Thanks

  • August 17, 2011
  • Like
  • 0

I am new to this, so please bear with me ...

 

I am trying to setup a trigger that will automatically populate the product of a case if a support tech enters a serial number, but if there is no serial number, leave the product field alone for the tech to use normally.

 

Within the Case object, I have the field Product (Product__c) which is a type Lookup(Product) and I have a field Serial Number (Serial_Number__c) which is a type Lookup(Asset).  (Our assets' names are the same as the serial numbers)

 

Under the Asset object, I have a the standard field of Product (Product2) which is a type Lookup(Product).

 

I want the trigger to run after insert and after update.  Essentially I want it to check the case to see if there is a Serial Number and if so, use the Product defined within the Asset (Serial Number).  This way I will not have issues where we get the Serial Number later, enter it in and have the wrong product on the case.

 

Below is my meager code, I know I am not doing something right as it is giving me a compile error on the where clause that I put in.  I don't think it is the right way to do it.

 

Thanks.

 

trigger updateProduct on Case (after insert, after update) {

Case myCase = trigger.new[0];
if (myCase.Serial_Number__c) {myCase.Product__c = Asset.Product2.Name where Asset.Name = myCase.Serial_Number__c; update myCase;}

}

 

The below trigger works great when it is managing on record at a time, but the trigger will return this error when more than one record is processed at the time. I thought the code was ulkified. What more needs to be done. Here is the trigger.

 

trigger cmOwner on CampaignMember (Before Insert, Before Update) {

    Set<Id> lIds = new Set<Id>();
    Set<Id> cIds = new Set<Id>();
    
    for(CampaignMember cm : Trigger.new) {
    System.debug('**** 1 lIds leadid: '+cm.leadid);
    System.debug('**** 1.5 cIds contactid : '+cm.contactid);

        LIds.add(cm.leadid);
        cids.add(cm.contactid);


    System.debug('**** 2 lIds leadid : '+cm.leadid);
    System.debug('**** 2.5 cIds contactid : '+cm.contactid);
    
   }
   String l;
   String user;
   String sUser;

   sUser = [select id from user where Name = 'Shayla Wentz'].id;
   List<contact> contact = [select ownerid from contact where id in:cIds];
   List<Lead> ow = [select ownerid from lead where id=:lids];

  System.debug('**** 2.5 ow : '+ow);

    List<user> leadowner = [select id from user where id =: ow[0].ownerid];
    
    System.debug('**** 3 leadowner : '+leadowner);
    
    for(CampaignMember c: trigger.new){
      If(leadowner != null){
        c.OwnerName__c = leadowner[0].id;
        System.debug('****************************aa 3 c.lead.ownerid : '+c.lead.ownerid);
        }  else{
        
        c.OwnerName__c = sUser;
        }
        
    if(c.contactid <> null){
        c.OwnerName__c = contact[0].ownerid;
        }
    }  
}

 

Thank you,

ckellie

I have a vf page that I am trying to display the mini page when I hover over the link. Below is my vf page link statement.

 

When I hover over the link I get a hover window but it is the mini page for the control but it has the sidebar and menu displayed. Also when i move off the link the page does not hide.

 

<a href="/{v.aid}" id="{!v.aid}{!day.DayName}{!day.dayofmonth}"                                           onblur="LookupHoverDetail.getHover('{!v.aid}{!day.DayName}{!day.dayofmonth}').hide();"                                           onmouseout="LookupHoverDetail.getHover('{!v.aid}{!day.DayName}{!day.dayofmonth}').hide();"                                           onfocus="LookupHoverDetail.getHover('{!v.aid}{!day.DayName}{!day.dayofmonth}','/{!v.aid}/m?retURL=%2Fapex%2FMilestone1_Calendar_Team&amp;isAjaxRequest=1&amp;nocache=1308340279175;').show();"         onmouseover="LookupHoverDetail.getHover('{!v.aid}{!day.DayName}{!day.dayofmonth}','/{!v.aid}/m?retURL=%2Fapex%2FMilestone1_Calendar_Team&amp;isAjaxRequest=1&amp;nocache=1308340279175;').show();">{!v.name}</a>

 

any help is a big thanks.

HI, 

 

I'm pretty new to this APEX lark and am not sure if I'm doing this right, so any assistance would be greatly appreciated. 

 

I have written a trigger (adapted from one that I have found online). The triggers purpose is to (before update) map the OwnerId field to a custom User Lookup of my custom object Change_Request__c. 

 

TRIGGER DETAIL

 

 

 
trigger onChangeReqBeforeUpdate on Change_Request__c (before update) {
    
    Set<Id> ownerIds = new Set<Id>();
    Map<Id, List<Change_Request__c>> owner = new Map<Id, List<Change_Request__c>>();
        for(Change_Request__c cr : trigger.new){
            ownerIds.add(cr.OwnerId);
            List<Change_Request__c> crq = new List<Change_Request__c>();
            if(owner.containsKey(cr.OwnerId)) crq = owner.get(cr.OwnerId);
               crq.add(cr);
               owner.put(cr.OwnerId, crq);
            } 
        for(User u : [SELECT Id FROM User WHERE Id IN :ownerIds]){
        for(Change_Request__c cr : owner.get(u.id)){
        
        cr.Assigned_To__c = u.Id;
        }
    }
    
}

 

Now this trigger works as expected. With this in mind I wanted to create a similar trigger that runs 'before insert' only. I copied the above code to a new trigger (below) on the same object. However this time I wish to map the CreatedById field to a custom User Lookup field. 

The new trigger however doesn't work, but I have no idea why... 

 
trigger onChangeReqBeforeInsert on Change_Request__c (before insert) {

    Set<Id> createdbyIds = new Set<Id>();
    Map<Id, List<Change_Request__c>> createdby = new Map<Id, List<Change_Request__c>>();

        for(Change_Request__c cr : trigger.new){
            createdbyIds.add(cr.CreatedById);
            List<Change_Request__c> crq = new List<Change_Request__c>();

            if(createdby.containsKey(cr.CreatedById)) crq = createdby.get(cr.CreatedById);
               crq.add(cr);
               createdby.put(cr.CreatedById, crq);
            } 

        for(User u : [SELECT Id FROM User WHERE Id IN :createdbyIds]){
        for(Change_Request__c cr : createdby.get(u.id)){
        
        cr.Requested_By__c = u.Id;

        }
    }
    
}

 

I would be most greaftul for some guidance in terms of writing test classes for this. 
Thanks in advance
Ben

 

 

Hi All

 

  I had displayed the dtae in a text box in VF page,But I need to dispaly the Error message when we enter the other than  date in the text box.

 The format should be while entering into the text box is year & month only.  this can be do using VF page,not a validation.

 please help me..

 

Thanks

Anu....

 

 

When you create a new trigger using the Force.com IDE, you get a file that looks like this:

 

trigger AccountTrigger on Account (after insert, after update) {

}

 

Is there a way to modify the template that is used to generate a trigger so when I create the trigger it would look like:

 

trigger AccountTrigger on Account (after insert, after update, before insert, before update) {

if(trigger.isInsert && trigger.isAfter){

//implement code

}

 

  if(trigger.isUpdate && trigger.isAfter){

   //implement code

  }

}

 

 

Hello.  Is there way a to adjust the various logging levels when deploying code to production using the IDE?  How about when running unit tests in production?  I want to turn off workflow and validation logging because the log size is overflowing.

 

thanks

David