• John Gerhard
  • NEWBIE
  • 90 Points
  • Member since 2015

  • Chatter
    Feed
  • 2
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 14
    Replies
Hi All,

I have created a custom button on Avail object which is a related list on Opportunity.
User-added image
Now, when I click on the button. The Opportunity Name is not populating.
User-added image


Can anyone please help if I am missing something in the logic.

User-added image

/a0O/e?CF00N500000032hk3={!Avail_Request__c.Opportunity__c}
&CF00N500000032hk3_lkid={!Avail_Request__c.OpportunityId__c}
&retURL=%2F0061g000002tm0Y

Regards,
Vikas
I'm working on an Apex custom controller for a Visualforce page.  After I perform an insert transaction for a new instance of a custom object, I want to redirect to a Contact detail page.

I have a field on the Apex class called myContact of type Contact and my constructor always makes sure it is valid and instantiated with a valid Contact based on URL parameters passed to the Visualforce page, so I always have a Contact.  After I do my new custom object insert, I invoke a method called returnToContact() which is shown below.  However, it doesn't redirect, leading me to believe I'm doing something wrong.
public PageReference returnToContact() {
        PageReference contactPage = new PageReference('/' + myContact.Id);
        contactPage.setRedirect(true);
        return contactPage;
}
Any ideas on what I need to do to ensure I can properly redirect?
Hello,

When a task is created I update a lookup field with the whoID if the whoID is a contact that is. However, when someone sends an email it does not fire the trigger. Apparently this is because it creates an object called EmailMessage and not just a Task, well it also creates a Task. The problem that arises is that when the task is created it is being done by an internal flow so it does not fire my trigger. Okay no problem, then I need to move my trigger to fire when the EmailMessage is created. Then I run into the issue of I don't know how to query for the task created that is associated with this email message to update the fields on the task accordingly. Any help would be much appreciated.
Hello,

I have a trigger on the task object before insert and before update. It works on the vast majority of my tasks, however it seems to not fire when a user uses the send email button on a contact. I can click edit and save and it will update fine but it will not fire on the insert of the task. Are the email tasks inserted in a special way compared to other tasks?
 
trigger TaskBeforeInsertBeforeUpdate on Task (before insert, before update) {

	// Initialize our lists we will use to query the related accounts and contacts later
	List<ID> accIDList = new List<ID>();
	List<ID> conIDList = new List<ID>();

	// Initialize our lists we will use to store our object querys
	List<Account> accList = new List<Account>();
	List<Contact> conList = new List<Contact>();


	// Loop through our tasks and assign the LCT variables, at the end we will build our lists of objects to query
	for (Task taskTrigger : Trigger.new) {
		String accIDString = String.Valueof(taskTrigger.WhatID);
		String conIDString = String.Valueof(taskTrigger.WhoID);

		if(conIDString == NULL){
			conIDString = '0';
		}

		if(accIDString == NULL){
			accIDString = '0';
		}

		if(taskTrigger.Call_Direction__c != NULL){
			taskTrigger.CallDisposition = taskTrigger.Call_Result__c;
			taskTrigger.CallType = taskTrigger.Call_Direction__c;
		}
		if(accIDString.startsWith('001')){
			taskTrigger.AccountLookup__c = taskTrigger.WhatID;
		}
		if(conIDString.startsWith('003')){
			taskTrigger.ContactLookUpField__c = taskTrigger.WhoID;
		}

		if(taskTrigger.qbdialer__Call_Date_Time__c != NULL && taskTrigger.status == 'Completed' && taskTrigger.AccountLookup__c != NULL){
			accIDList.add(taskTrigger.WhatID);
		}

		if(taskTrigger.ContactLookUpField__c != NULL && taskTrigger.status == 'Completed' && taskTrigger.qbdialer__Call_Date_Time__c != NULL){
			conIDList.add(taskTrigger.WhoID);
		}
	}

	// Query and update our contacts
	if(conIDList.size()>0){
		conList = [SELECT ID, qbdialer__Dials__c, AccountID, qbdialer__LastCallTime__c, OpportunityStage__c FROM Contact WHERE ID IN: conIDList];

		for(Task taskTrigger : Trigger.new){
			for(Contact con : conList){
				if(taskTrigger.WhoID == con.Id && (taskTrigger.qbdialer__Call_Date_Time__c > con.qbdialer__LastCallTime__c || con.qbdialer__LastCallTime__c == NULL)){
					con.qbdialer__LastCallTime__c = taskTrigger.qbdialer__Call_Date_Time__c;
					if(con.qbdialer__Dials__c == NULL){
						con.qbdialer__Dials__C = 0;
					}
					con.qbdialer__Dials__C += 1;
					if(taskTrigger.AccountLookup__c != con.AccountID){
						taskTrigger.AccountLookup__c = con.AccountID;
						taskTrigger.WhatID = con.AccountID;
						accIDList.add(con.AccountID);
					}
				}
			}
		}
		update conList;
	}

	// Query and update our accounts
	if(accIDList.size()>0){
		accList = [SELECT ID, qbdialer__Dials__c, qbdialer__LastCallTime__c, Type, Status__C FROM Account WHERE ID IN: accIDList];

		for(Task taskTrigger : Trigger.new){
			for(Account acc : accList){
				if(taskTrigger.AccountLookup__c == acc.Id && (taskTrigger.qbdialer__Call_Date_Time__c > acc.qbdialer__LastCallTime__c || acc.qbdialer__LastCallTime__c == NULL)){
				//if(taskTrigger.AccountLookup__c == acc.Id){
					acc.qbdialer__LastCallTime__c = taskTrigger.qbdialer__Call_Date_Time__c;
					if(acc.qbdialer__Dials__c == NULL){
						acc.qbdialer__Dials__c = 0;
					}
					acc.qbdialer__Dials__C += 1;
				}
			}
		}
		update accList;

	}

 
Hello, fairly new at VisualForce and Apex. I am running into an issue I can not seem to figure out. I am using a page block table and I want to limit the height of each row, as the comments section of some records could be 100 lines which makes the table massive while others are 1-2 lines. I would like to limit the row to 3 lines or 25px. In the screenshot below you can see the 5th record/row is taking up a ton of room and I would like to limit the height of it.

User-added image

Here is the code for that table specifically...
 
<!-- Task History and Call History -->
            <apex:pageBlock title="Task History/Call History">

             <div align="center">
            <apex:commandButton action="{!saveOldTasks}" value="Save Task Changes" id="saveTaskChangeButton" style="display:none"/>
            </div>

            <apex:pageBlockTable value="{!taskHistory}" var="o" title="Task History" id="closedTaskTable" >
                <apex:column headerValue="Subject">
                    <apex:outputLink value="{!URLFOR($Action.Task.View, o.Id)}">
                    {!o.Subject}
                    </apex:outputLink>
                </apex:column>
                <apex:column value="{!o.Call_Result__c}"/>
                <apex:column Headervalue="Comments">
                    <apex:outputField value="{!o.Description}" >
                    <apex:inlineEditSupport event="ondblclick" showOnEdit="saveTaskChangeButton"/>
                </apex:outputField>
            </apex:column>
                <apex:column value="{!o.ActivityDate}"/>
                <apex:column value="{!o.qbdialer__Call_Date_Time__c}"/>
                <apex:column value="{!o.OwnerID}"/>
            </apex:pageBlockTable>

            </apex:pageBlock>

 
I am working on transitioning my org to lightning, so I am working in one of my sandboxes and everytime I load a page I get a show notifications pop up allow/block. I have tried going into chrome settings and allowing the domain, of course clicking the allow button, the block button, and even block the domain. No matter what I do I get this pop-up every single time a page loads, it is not role/profile/user specific either. Here is a screenshot of the pop-up as well. How do I make this thing go away? I did turn off notifications in the setup menu as well, that did not work.
User-added image
Hello,

Okay, I have played with Apex and built a few triggers/classes and they have worked perfectly I have also made them bulkified and I am getting pretty savvy there.

My next project is to receive an XML file from an external source, parse that xml file and create a custom object called Verification. Inside this object we have a few fields called phone number, status(picklist), and name(text field.) So I did the trail heads for API beginner and a few of the advanced one, the problem I am running into is that I can't find anything that teaches me how to recieve a file, process it, and create an object. Everything I can find is send out a request and then get the response from the request and blah blah... So I have no idea where to even start with this one. I am pretty sure I need to use the SOAP API, other then that I am not sure how to send the file to SalesForce, or how to process the file to match what SalesForce needs to create the record. I think if I can get some help for those first two parts I can easily knock it out from there.

I think optimally what I am looking for is a tutorial of how to recieve the XML file like what credentials do I need to give to the sender, how to see how the file looks coming in, and then how to parse it to make sense to SalesForce.

Thank you,
Hello Everyone,

I can't figure this one out. Basically, I am assigning the API label of a field on my opportunity to a product field to easily create a list called oppFieldsList. Run a SOQL to grab all the fields and then go through and update those fields on the opportunity with the unit price. Here is my code snippet, hopefully someone has the right idea so I don't have to create if elses for 150 fields >.< Thank you in advance!
 
trigger OpportunityLineItemAfterUpdateAfterInsert on OpportunityLineItem (after update, after insert) {

    List<ID> oppIDList = new List<ID>();
    List<String> oppFieldsList = new List<String>();
    List<Opportunity> oppFieldsToUpdate = new List<Opportunity>();
    Integer i = 0;
    
    for (OpportunityLineItem oppLI : Trigger.new) {
        oppIDList.add(oppLI.OpportunityId);
        oppFieldsList.add(oppLI.Opportunity_Product_Field__c);
    }
    
    List<Opportunity> oppFields = [SELECT oppFieldsList FROM Opportunity WHERE Id IN: oppIDList];
    
    for (OpportunityLineItem oppLI : Trigger.new) {
        oppFieldsToUpdate.add(oppFields.put(oppFieldsList[i],oppLI.UnitPrice));
        i++;
    }
    
    update oppFieldsToUpdate;
}

 
Hey guys, I am running into an issue with too many SOQL queries when I try a bulk test of my code. The weird part is I run into the issue when I have 25 or more pricebook entries. I'd imagine it is something little.

 
trigger ProductsCreatedonOpp on Opportunity (after insert) {
            
    		//Initiate a list of strings for the SOQL to pull all the products we need
   			List<String> oppsStringList = new List<String>();
    		//Initiate a list that will hold all of the line items we will need to insert
    		List<OpportunityLineitem> lines = new List<OpportunityLineItem>();
    
    		//Fill the oppsStringList with the base quote template we want to filter the SOQL with
    		for (Opportunity opps : Trigger.New){
        		oppsStringList.add(opps.Base_Quote_Tempalte__c);
    		}
    
    		System.debug('1');
    
    		//Build an array with all of the products we want to add to our opportunity
    		List<PriceBookEntry> priceBookList = [SELECT Name,Id,unitPrice FROM PricebookEntry WHERE Quote_Template_Type__c IN:oppsStringList];
    
    		System.debug('2');
    
    		System.debug(priceBookList.size());
    
    		for(PricebookEntry priceBookEntries : priceBookList) {
        		System.debug(priceBookEntries.Id);
    		}
    
     		System.debug('3');
    
    		//Run through each opportunity and then add each product to the lines list to insert
    		for(Opportunity opps: Trigger.new){
    				for (PricebookEntry productsToAdd : priceBookList){
        				lines.add(new OpportunityLineItem(PriceBookEntryID=productsToAdd.Id, OpportunityID=opps.Id,
                	                             		 UnitPrice=productsToAdd.UnitPrice, Quantity=opps.of_Screens_per_Month__c));       	
    				}
       		 	}     
   		 	System.debug(lines);
    		//Insert all of the products into the Opportunities
    		insert lines;
}

 
I am working on transitioning my org to lightning, so I am working in one of my sandboxes and everytime I load a page I get a show notifications pop up allow/block. I have tried going into chrome settings and allowing the domain, of course clicking the allow button, the block button, and even block the domain. No matter what I do I get this pop-up every single time a page loads, it is not role/profile/user specific either. Here is a screenshot of the pop-up as well. How do I make this thing go away? I did turn off notifications in the setup menu as well, that did not work.
User-added image
Hello,

I have a trigger on the task object before insert and before update. It works on the vast majority of my tasks, however it seems to not fire when a user uses the send email button on a contact. I can click edit and save and it will update fine but it will not fire on the insert of the task. Are the email tasks inserted in a special way compared to other tasks?
 
trigger TaskBeforeInsertBeforeUpdate on Task (before insert, before update) {

	// Initialize our lists we will use to query the related accounts and contacts later
	List<ID> accIDList = new List<ID>();
	List<ID> conIDList = new List<ID>();

	// Initialize our lists we will use to store our object querys
	List<Account> accList = new List<Account>();
	List<Contact> conList = new List<Contact>();


	// Loop through our tasks and assign the LCT variables, at the end we will build our lists of objects to query
	for (Task taskTrigger : Trigger.new) {
		String accIDString = String.Valueof(taskTrigger.WhatID);
		String conIDString = String.Valueof(taskTrigger.WhoID);

		if(conIDString == NULL){
			conIDString = '0';
		}

		if(accIDString == NULL){
			accIDString = '0';
		}

		if(taskTrigger.Call_Direction__c != NULL){
			taskTrigger.CallDisposition = taskTrigger.Call_Result__c;
			taskTrigger.CallType = taskTrigger.Call_Direction__c;
		}
		if(accIDString.startsWith('001')){
			taskTrigger.AccountLookup__c = taskTrigger.WhatID;
		}
		if(conIDString.startsWith('003')){
			taskTrigger.ContactLookUpField__c = taskTrigger.WhoID;
		}

		if(taskTrigger.qbdialer__Call_Date_Time__c != NULL && taskTrigger.status == 'Completed' && taskTrigger.AccountLookup__c != NULL){
			accIDList.add(taskTrigger.WhatID);
		}

		if(taskTrigger.ContactLookUpField__c != NULL && taskTrigger.status == 'Completed' && taskTrigger.qbdialer__Call_Date_Time__c != NULL){
			conIDList.add(taskTrigger.WhoID);
		}
	}

	// Query and update our contacts
	if(conIDList.size()>0){
		conList = [SELECT ID, qbdialer__Dials__c, AccountID, qbdialer__LastCallTime__c, OpportunityStage__c FROM Contact WHERE ID IN: conIDList];

		for(Task taskTrigger : Trigger.new){
			for(Contact con : conList){
				if(taskTrigger.WhoID == con.Id && (taskTrigger.qbdialer__Call_Date_Time__c > con.qbdialer__LastCallTime__c || con.qbdialer__LastCallTime__c == NULL)){
					con.qbdialer__LastCallTime__c = taskTrigger.qbdialer__Call_Date_Time__c;
					if(con.qbdialer__Dials__c == NULL){
						con.qbdialer__Dials__C = 0;
					}
					con.qbdialer__Dials__C += 1;
					if(taskTrigger.AccountLookup__c != con.AccountID){
						taskTrigger.AccountLookup__c = con.AccountID;
						taskTrigger.WhatID = con.AccountID;
						accIDList.add(con.AccountID);
					}
				}
			}
		}
		update conList;
	}

	// Query and update our accounts
	if(accIDList.size()>0){
		accList = [SELECT ID, qbdialer__Dials__c, qbdialer__LastCallTime__c, Type, Status__C FROM Account WHERE ID IN: accIDList];

		for(Task taskTrigger : Trigger.new){
			for(Account acc : accList){
				if(taskTrigger.AccountLookup__c == acc.Id && (taskTrigger.qbdialer__Call_Date_Time__c > acc.qbdialer__LastCallTime__c || acc.qbdialer__LastCallTime__c == NULL)){
				//if(taskTrigger.AccountLookup__c == acc.Id){
					acc.qbdialer__LastCallTime__c = taskTrigger.qbdialer__Call_Date_Time__c;
					if(acc.qbdialer__Dials__c == NULL){
						acc.qbdialer__Dials__c = 0;
					}
					acc.qbdialer__Dials__C += 1;
				}
			}
		}
		update accList;

	}

 
Step 1: Launch your Trailhead Playground by clicking Launch from any hands-on challenge.
when I select "Challenge" It takes me to the quiz.
Where is the Playground????
Hi All,

I have created a custom button on Avail object which is a related list on Opportunity.
User-added image
Now, when I click on the button. The Opportunity Name is not populating.
User-added image


Can anyone please help if I am missing something in the logic.

User-added image

/a0O/e?CF00N500000032hk3={!Avail_Request__c.Opportunity__c}
&CF00N500000032hk3_lkid={!Avail_Request__c.OpportunityId__c}
&retURL=%2F0061g000002tm0Y

Regards,
Vikas
I'm working on an Apex custom controller for a Visualforce page.  After I perform an insert transaction for a new instance of a custom object, I want to redirect to a Contact detail page.

I have a field on the Apex class called myContact of type Contact and my constructor always makes sure it is valid and instantiated with a valid Contact based on URL parameters passed to the Visualforce page, so I always have a Contact.  After I do my new custom object insert, I invoke a method called returnToContact() which is shown below.  However, it doesn't redirect, leading me to believe I'm doing something wrong.
public PageReference returnToContact() {
        PageReference contactPage = new PageReference('/' + myContact.Id);
        contactPage.setRedirect(true);
        return contactPage;
}
Any ideas on what I need to do to ensure I can properly redirect?
I'm working on Navigate and Personalize Salesforce and trying to complete the second activity. I've launched Trailhead Playground 1 and I'm supposed to do the following: Customize your account detail page layout. Make the Open Activities related list the first one you see on accountrecord detail pages. Then create an account called Goat Wranglers R Us and check the account page to make sure Open Activities appears first.

I did make Activities the first one you see and I did create an account called Goat . . . but when I click Check Challenge I get the following message: Challenge Not yet complete... here's what's wrong: 
The "Open Activities" related list does not appear to the first one on the Account record details page. Make sure that you are not using Record Types with Accounts as this prevents us from checking the layouts.


Then I see that I skipped pass this Reminder: Remember, this module is meant for Salesforce Classic. When you launch your hands-on org, switch to Salesforce Classic to complete this challenge.

I don't know how to switch to Salesforce Classic, If someone can help me with this, I would appreciate it.

Thanks.

Chip
Hello, fairly new at VisualForce and Apex. I am running into an issue I can not seem to figure out. I am using a page block table and I want to limit the height of each row, as the comments section of some records could be 100 lines which makes the table massive while others are 1-2 lines. I would like to limit the row to 3 lines or 25px. In the screenshot below you can see the 5th record/row is taking up a ton of room and I would like to limit the height of it.

User-added image

Here is the code for that table specifically...
 
<!-- Task History and Call History -->
            <apex:pageBlock title="Task History/Call History">

             <div align="center">
            <apex:commandButton action="{!saveOldTasks}" value="Save Task Changes" id="saveTaskChangeButton" style="display:none"/>
            </div>

            <apex:pageBlockTable value="{!taskHistory}" var="o" title="Task History" id="closedTaskTable" >
                <apex:column headerValue="Subject">
                    <apex:outputLink value="{!URLFOR($Action.Task.View, o.Id)}">
                    {!o.Subject}
                    </apex:outputLink>
                </apex:column>
                <apex:column value="{!o.Call_Result__c}"/>
                <apex:column Headervalue="Comments">
                    <apex:outputField value="{!o.Description}" >
                    <apex:inlineEditSupport event="ondblclick" showOnEdit="saveTaskChangeButton"/>
                </apex:outputField>
            </apex:column>
                <apex:column value="{!o.ActivityDate}"/>
                <apex:column value="{!o.qbdialer__Call_Date_Time__c}"/>
                <apex:column value="{!o.OwnerID}"/>
            </apex:pageBlockTable>

            </apex:pageBlock>

 
Hello,

Okay, I have played with Apex and built a few triggers/classes and they have worked perfectly I have also made them bulkified and I am getting pretty savvy there.

My next project is to receive an XML file from an external source, parse that xml file and create a custom object called Verification. Inside this object we have a few fields called phone number, status(picklist), and name(text field.) So I did the trail heads for API beginner and a few of the advanced one, the problem I am running into is that I can't find anything that teaches me how to recieve a file, process it, and create an object. Everything I can find is send out a request and then get the response from the request and blah blah... So I have no idea where to even start with this one. I am pretty sure I need to use the SOAP API, other then that I am not sure how to send the file to SalesForce, or how to process the file to match what SalesForce needs to create the record. I think if I can get some help for those first two parts I can easily knock it out from there.

I think optimally what I am looking for is a tutorial of how to recieve the XML file like what credentials do I need to give to the sender, how to see how the file looks coming in, and then how to parse it to make sense to SalesForce.

Thank you,
Hello Everyone,

I can't figure this one out. Basically, I am assigning the API label of a field on my opportunity to a product field to easily create a list called oppFieldsList. Run a SOQL to grab all the fields and then go through and update those fields on the opportunity with the unit price. Here is my code snippet, hopefully someone has the right idea so I don't have to create if elses for 150 fields >.< Thank you in advance!
 
trigger OpportunityLineItemAfterUpdateAfterInsert on OpportunityLineItem (after update, after insert) {

    List<ID> oppIDList = new List<ID>();
    List<String> oppFieldsList = new List<String>();
    List<Opportunity> oppFieldsToUpdate = new List<Opportunity>();
    Integer i = 0;
    
    for (OpportunityLineItem oppLI : Trigger.new) {
        oppIDList.add(oppLI.OpportunityId);
        oppFieldsList.add(oppLI.Opportunity_Product_Field__c);
    }
    
    List<Opportunity> oppFields = [SELECT oppFieldsList FROM Opportunity WHERE Id IN: oppIDList];
    
    for (OpportunityLineItem oppLI : Trigger.new) {
        oppFieldsToUpdate.add(oppFields.put(oppFieldsList[i],oppLI.UnitPrice));
        i++;
    }
    
    update oppFieldsToUpdate;
}

 
Hey guys, I am running into an issue with too many SOQL queries when I try a bulk test of my code. The weird part is I run into the issue when I have 25 or more pricebook entries. I'd imagine it is something little.

 
trigger ProductsCreatedonOpp on Opportunity (after insert) {
            
    		//Initiate a list of strings for the SOQL to pull all the products we need
   			List<String> oppsStringList = new List<String>();
    		//Initiate a list that will hold all of the line items we will need to insert
    		List<OpportunityLineitem> lines = new List<OpportunityLineItem>();
    
    		//Fill the oppsStringList with the base quote template we want to filter the SOQL with
    		for (Opportunity opps : Trigger.New){
        		oppsStringList.add(opps.Base_Quote_Tempalte__c);
    		}
    
    		System.debug('1');
    
    		//Build an array with all of the products we want to add to our opportunity
    		List<PriceBookEntry> priceBookList = [SELECT Name,Id,unitPrice FROM PricebookEntry WHERE Quote_Template_Type__c IN:oppsStringList];
    
    		System.debug('2');
    
    		System.debug(priceBookList.size());
    
    		for(PricebookEntry priceBookEntries : priceBookList) {
        		System.debug(priceBookEntries.Id);
    		}
    
     		System.debug('3');
    
    		//Run through each opportunity and then add each product to the lines list to insert
    		for(Opportunity opps: Trigger.new){
    				for (PricebookEntry productsToAdd : priceBookList){
        				lines.add(new OpportunityLineItem(PriceBookEntryID=productsToAdd.Id, OpportunityID=opps.Id,
                	                             		 UnitPrice=productsToAdd.UnitPrice, Quantity=opps.of_Screens_per_Month__c));       	
    				}
       		 	}     
   		 	System.debug(lines);
    		//Insert all of the products into the Opportunities
    		insert lines;
}