• tric
  • NEWBIE
  • 100 Points
  • Member since 2012

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 65
    Questions
  • 59
    Replies

So here's the use case.

 

I have a custom object (Order__c) which has a lookup to a Contact (Vendor_Name__c, on the Order Object). Contacts do not have lookups to Order.

 

On the Order, there is a Valuation_Contracted_Date__c field. A contact can have multiple Orders (10, 50, 150) - and i'd like for this trigger to always set on the Contact (Last_Engaged_Date__c) to the latest Contracted Date.

 

So I think I have something...but it needs help. Right now the error is "Save error: Didn't understand relationship 'Order__c' in FROM part of query call."

 

 

tldr; query all orders on that contact, order by valuation contracted date descending, limit 1. take that date and update the contact with it.

 

trigger lastEngagedDate on Order__c (before insert, before update) {

	try {
		for(Order__c o : Trigger.new) {
			
			Contact c = [SELECT Last_Engaged_Date__c, 
				(SELECT Valuation_Contracted_Date__c FROM Order__c WHERE c.Id = :Vendor_Name__c ORDER BY                                        Valuation_Contracted_Date__c DESC LIMIT 1) 
				FROM Contact 
					WHERE Id = :o.Vendor_Name__c];
			
			if(o.Status__c == 'Valuation Received') {		
				c.Last_Engaged_Date__c = o.Valuation_Contracted_Date__c;
				update c;			
			} 
		}
	}
	catch(Exception e) {		
	}	
	
}

 

Attempt #2 - still doesn't work?

 

trigger lastEngagedDate on Order__c (before insert, before update) {

	try {
		for(Order__c o : Trigger.new) {
			Contact c = [SELECT Id, Last_Engaged_Date__c FROM Contact WHERE Id = :o.Vendor_Name__c];	
			Order__c o = [SELECT Valuation_Contracted_Date__c FROM Order__c WHERE c.Id =:o.Vendor_Name__c
							ORDER BY Valuation_Contracted_Date__c
							LIMIT 1];
			
			if(o.Status__c == 'Valuation Received') {
				c.Last_Engaged_Date__c = o.Valuation_Contracted_Date__c;
				update c;
			} 
		}
	}
	catch(Exception e) {
	}
	
}

 


 


  • February 17, 2012
  • Like
  • 0

I'm getting this error when I try to update a contact record:

 

Review all error messages below to correct your data.
Apex trigger ContactStageTrigger caused an unexpected exception, contact your administrator: ContactStageTrigger: execution of AfterUpdate caused by: System.FinalException: Record is read-only: Trigger.ContactStageTrigger: line 6, column 1

 

Here is my Code:

 

trigger ContactStageTrigger on Contact (after insert, after update) {

    Contact myContact = trigger.new[0];
    Account myAccount = [SELECT OwnerId FROM Account WHERE Id = :myContact.AccountId];
    if(myContact.Status__c == 'Prospect'){
        myContact.OwnerId = myAccount.OwnerId;
        update myContact;
    }
 }

 


Evening World,

 

I am using the following Apex Trigger and Test Class:

 

trigger AutoAllocateDelegatesToTrainingActions on Training__c (before insert) {
{
	List<Employee_Training_Action__c> listETA = new List<Employee_Training_Action__c> ();
	
	for (Training__C T : trigger.new)
	if(Trigger.isInsert)
	{
	
		
			Employees__c Emp = [SELECT Id FROM Employees__c WHERE Works_Nights_Weekdays__c = TRUE];
			
			listETA.add(new Employee_Training_Action__c(
			Training_Action__c = T.id,
			Employee__c = Emp.id));
		
		if(listETA.size() >0)
		{
			insert listETA;	
		}
	}
}
}

 

@isTest
private class Test_TA_DelegateAllocation {
static testMethod void myUnitTest9()
{
	Service_Agreement__c SA = new Service_Agreement__c ();
	SA.Name = 'Test SA';
	insert SA;
	Training__c TR = new Training__c ();
	TR.Service_Agreement__c=SA.Id;
	insert TR;
	Employee_Training_Action__c ETA = new Employee_Training_Action__c ();
	ETA.Training_Action__c=TR.Id;
	ETA.Employee__c = 'a0l20000001IYYN';
try{	
	insert ETA;}
 catch(System.DmlException e){            
 System.debug('we caught a dml exception: ' + e.getDmlMessage(0));
	}
}
}

 However, when deploying to production I am getting the following error:

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AutoAllocateDelegatesToTrainingActions: execution of BeforeInsert

caused by: System.QueryException: List has more than 1 row for assignment to SObject

Trigger.AutoAllocateDelegatesToTrainingActions: line 10, column 23: []

 

I understand what the error is saying, and it is correct, there will be more than one record to create, however, how do i tell the system that this is 'ok'!

 

Help much apprecaited.

 

Steve

Hi Friends, We have security certificate installed on the server.Now when we connect salesforce with the web services hosted on the server then we get unable to tunnel through proxy,http 1.0 ,service unavailable error message. The person who has been looking at the server is telling me to install client side certificate on the salesforce side.Do I need client certificate?.I don't think so In one way SSL,Do I need to have client side certificate or server side certificate?I guess I need server side certificate not the client side certificate. Can somebody help? Thanks, Trick
  • November 16, 2012
  • Like
  • 0
Hi Friends, From the salesforce customer portal which is accessible to outside public, when somebody request something such as web service then which IP address is used .Is that customers IP address or salesforce IP address will be used to access web services from salesforce portal? Any reply will be highly appreciated? Thanks, Trick
  • November 15, 2012
  • Like
  • 0
Hi Friends, From the salesforce customer portal which is accessible to outside public, when somebody request something such as web service then which IP address is used .Is that customers IP address or salesforce IP address will be used to access web services from salesforce portal? Any reply will be highly appreciated? Thanks, Trick
  • November 15, 2012
  • Like
  • 0
Hi friends, when I try to access webservices hosted on the server from salesforce customer portal I get an error message,unable to tunnel through Proxy http,1.0 service unavailable. Can IP Whitelist help me in this?If it then please answer the following questions Q-1 Where do I need to add IP addresses to ensure that salesfiorce can communicate with server hosting webservices? Q- 2 I keep on moving from Europe to Asia and I access salesforce from Asia.Once I have got salesforce IP addresses added to the server hosting web services(I am guessing that I need to add IP addresses on the server hosting web services) ,Will I be able to access my webservices from salesforce while sitting in Asia. Q-3 After adding IP addresses.Will I be able to Login to salesforce while I am in Asia?. Can somebody Help? Thanks, Trick
  • November 14, 2012
  • Like
  • 0
Issue is:- I am using rest based webservices and I have exposed endpoint URL in Apex class and to this URL I am passing username and other information which has been collected after querying salesforce.Everything works well when I am passing information using http (means no ssl is involved).However,When I use Https(which means ssl)then salesforce throws an exception such as unable to tunnel through proxy,http 1.0 service unavailable. What could be the reasons for this ,Unable to tunnel through proxy1.0 ,service unavailable error? I do not think that I can use SOAP UI as this is rest based services. What is IP Whitelist? Will it help If i get it added on the server which is hosting this web services? customers who will be using this application are portal customers.So they will no more be salesforce org users.Do you think Ip whitelist will work Can somebody please throw some light on this?
  • November 13, 2012
  • Like
  • 0
Hi Friends, We are accessing page on the portal and the below given error is thrown directly to the customer on the page. Error: Error occurred while loading a Visualforce page. First, We have written apex class and V.f page .In apex class I making request to the webservices on the server and the response which I get is displayed in Iframe to the customer. This works fine when endpoint URL is without SSL(meaning Http). No error However,It doesn't when we have Https (meaning with SSL). It looks like some problem on the server with SSL Because I get an error,Unable to pass through proxy ,Https service 1.0 unavailable(Captured in debug logs ,not shown to the customer).The one which is shown to the customer is Error: Error occurred while loading a Visualforce page .Is this a standard error message whenever Salesforce is not able to load page? Any idea why debug logs is generating the following error message when we are trying to access web services on the server I get an error,Unable to tunnel through proxy. Proxy returns "HTTP/1.0 503 Service Unavailable". Any insights on this will be greatly appreciated Thanks, Trick
  • November 13, 2012
  • Like
  • 0
Hi Friends, We are accessing page on the portal and the below given error is thrown directly to the customer on the page. Error: Error occurred while loading a Visualforce page. First, We have written apex class and V.f page .In apex class I making request to the webservices on the server and the response which I get is displayed in Iframe to the customer. This works fine when endpoint URL is without SSL(meaning Http). No error However,It doesn't when we have Https (meaning with SSL). It looks like some problem on the server with SSL Because I get an error,Unable to pass through proxy ,Https service 1.0 unavailable(Captured in debug logs ,not shown to the customer).The one which is shown to the customer is Error: Error occurred while loading a Visualforce page .Is this a standard error message whenever Salesforce is not able to load page? Any idea why debug logs is generating the following error message when we are trying to access web services on the server I get an error,Unable to tunnel through proxy. Proxy returns "HTTP/1.0 503 Service Unavailable". Any insights on this will be greatly appreciated Thanks, Trick
  • November 13, 2012
  • Like
  • 0
Hi Friends, We have 1) Total Salesforce Licenses 53 2) Used Licenses 50 3) Remaining licenses 3 But I need to create 4 more user accounts in salesforce.Can I deactivate some users and then create those 4 users ,will it allow me to create those accounts. Can somebody answer? Thanks, Trick
  • November 06, 2012
  • Like
  • 0
https://bbh_webservices.cityofboston.gov/Secure/GetUserUrl Hi Friends, I am trying to register URL in the remote settings but it is not letting me register.It gives me an error Error: Unable to parse URI For Example if I use: https://Chicago_webservices. Error: Unable to parse URI However:if we change it to Https://Chicago.webservices then it accepts. Does it not let regiter URL with in the remote settings with Underscore?.Any idea about that.
  • October 25, 2012
  • Like
  • 0
Hi Friends, I am trying to register URL in the remote settings but it is not letting me register.It gives me an error Error: Unable to parse URI For Example if I use: https://Chicago_webservices. Error: Unable to parse URI However:if we change it to Https://Chicago.webservices then it accepts. Does it not let register URL with in the remote settings with Underscore?.Any idea about that. Thanks, Trick
  • October 25, 2012
  • Like
  • 0
HI Friends, I have Salesforce portal and another portal on another CRM.We have linked these two portals with each other.Now,when some body changes password on salesforce portal.As soon as he clicks on the submit button then we want to show message to the user that Please change the password on another portal also and keep the same password which is salesforce password. Please let me know if somebody has done this or any ideas are most welcome and how we can accomplish this Thanks, Trick
  • October 24, 2012
  • Like
  • 0
HI Friends, I have Salesforce portal and another portal on another CRM.We have linked these two portals with each other.Now,when some body changes password on salesforce portal.As soon as he clicks on the submit button then we want to show message to the user that Please change the password on another portal also and keep the same password which is salesforce password. Please let me know if somebody has done this or any ideas are most welcome and how we can accomplish this Thanks, Trick
  • October 24, 2012
  • Like
  • 0
Hi Friends, I have apex class written and whose function I have specified in the action parameter of the apex page tag in visual force and I also have Iframe running on the same page I want to know will this function get's executed before the iframe and this function of the apex class executes on the salesforce server or not. Thanks, Trick
  • September 05, 2012
  • Like
  • 0
Hi Friends, I have integrated salesforce with do net application.So as part of the integration I am calling dot net application in Iframe. When I run application in an Iframe,it gives an error and give me broken link Basically in the browser I see two URL's,one is the salesforce URl and I have no idea from where that URL is coming whereas the other URL is the URl which I need. https://c.cs14.visual.force.com/apex/"http://bbh.webservices.citybb.com/Pe/In? Can somebody throw some light on this.?Is this a known bug? Thanks, Trick
  • September 05, 2012
  • Like
  • 0
Hi Friends , When I run rest based web services.Following exception gets raised.Has anyone got any idea what this exception means and how to get rid of it? JSONException: A JSONObject text must begin with { Thanks, Trick
  • August 23, 2012
  • Like
  • 0
Hi Friends, I have Rich text area field and in this field a link has been supplied.I want to pass parameters to this link in the form of query string.Is there way to do that.?Can somebody advice?. Thanks, Trick
  • August 20, 2012
  • Like
  • 0
Hi Friends, I have apex class and visual force page.The class is fetching portal customers ,email, firstname, lastname .I am calling that function in visual force page and passing these parameters to the link which is running in IFrame. I have been able to pass email name .How do I pass firstname and lastname to the the link ,Can somebody make changes and and show me how to pass firstname and lastname to the link in iframe public class pageTest { public String UserMail; string userId = UserInfo.getUserId(); public String getUserMail() { return UserMail = [SELECT Email,firstname,lastname FROM User WHERE Id =: userId].Email; }
  • August 20, 2012
  • Like
  • 0
Hi Friends, I have standard rich text field on the custom object and in this field we have text as well as some hyperlink. When customer clicks on the hyperlink it opens another window.I need to pass parameters to this window in the form of query string.However,I am not able to do that. Can somebody help or show how this can be accomplished? Any pointers in this direction will be great. Thanks, Trick
  • August 08, 2012
  • Like
  • 0
Hi Friends, I have flow on the portal which has been created by somebody else.Customer after completing the flow press finish button then he sees a long text. I am not able to figure out from where this text is coming .Is it a part of the flow or something else. Can somebody give me some pointers? Thanks, Trick
  • August 07, 2012
  • Like
  • 0
Hi Friends, We are implementing search mechanism in salesforce.Some customer put's his email address in search field and now web services makes a callout to the web services which in turn is going to return couple of values.Now I need to store these values in the table and show to the customer.These values will keep changing. However,I am not storing these values in the salesforce database.So I am not sure how I am going to display them in salesforce in the form of table. Can somebody throw some light on this.How this can be accomplished? Thanks, Trick
  • August 06, 2012
  • Like
  • 0
Hi Friends, From the salesforce customer portal which is accessible to outside public, when somebody request something such as web service then which IP address is used .Is that customers IP address or salesforce IP address will be used to access web services from salesforce portal? Any reply will be highly appreciated? Thanks, Trick
  • November 15, 2012
  • Like
  • 0
Hi Friends, We are accessing page on the portal and the below given error is thrown directly to the customer on the page. Error: Error occurred while loading a Visualforce page. First, We have written apex class and V.f page .In apex class I making request to the webservices on the server and the response which I get is displayed in Iframe to the customer. This works fine when endpoint URL is without SSL(meaning Http). No error However,It doesn't when we have Https (meaning with SSL). It looks like some problem on the server with SSL Because I get an error,Unable to pass through proxy ,Https service 1.0 unavailable(Captured in debug logs ,not shown to the customer).The one which is shown to the customer is Error: Error occurred while loading a Visualforce page .Is this a standard error message whenever Salesforce is not able to load page? Any idea why debug logs is generating the following error message when we are trying to access web services on the server I get an error,Unable to tunnel through proxy. Proxy returns "HTTP/1.0 503 Service Unavailable". Any insights on this will be greatly appreciated Thanks, Trick
  • November 13, 2012
  • Like
  • 0
https://bbh_webservices.cityofboston.gov/Secure/GetUserUrl Hi Friends, I am trying to register URL in the remote settings but it is not letting me register.It gives me an error Error: Unable to parse URI For Example if I use: https://Chicago_webservices. Error: Unable to parse URI However:if we change it to Https://Chicago.webservices then it accepts. Does it not let regiter URL with in the remote settings with Underscore?.Any idea about that.
  • October 25, 2012
  • Like
  • 0
Hi Friends, I have apex class written and whose function I have specified in the action parameter of the apex page tag in visual force and I also have Iframe running on the same page I want to know will this function get's executed before the iframe and this function of the apex class executes on the salesforce server or not. Thanks, Trick
  • September 05, 2012
  • Like
  • 0
Hi Friends, I have integrated salesforce with do net application.So as part of the integration I am calling dot net application in Iframe. When I run application in an Iframe,it gives an error and give me broken link Basically in the browser I see two URL's,one is the salesforce URl and I have no idea from where that URL is coming whereas the other URL is the URl which I need. https://c.cs14.visual.force.com/apex/"http://bbh.webservices.citybb.com/Pe/In? Can somebody throw some light on this.?Is this a known bug? Thanks, Trick
  • September 05, 2012
  • Like
  • 0
Hi Friends, I have flow on the portal which has been created by somebody else.Customer after completing the flow press finish button then he sees a long text. I am not able to figure out from where this text is coming .Is it a part of the flow or something else. Can somebody give me some pointers? Thanks, Trick
  • August 07, 2012
  • Like
  • 0

Hi Friends, We have customer portal and we want to capture logged in user information such as password .We are using default salesforce portal functionality. can somebody give an example of how to do it? Thanks, Trick

Hi Friends,

 

I have visual force tab in salesforce.So when somebody navigates away from the tab ,for example,clicks on some other tab then he should see a dialog box which says that,Are u sure that you want to naviage away from this page?

 

Below given code does not belong to me.However,it does  run and show dialog box with the message:-

This page is asking you to confirm that you want to leave - data you have entered may not be saved

 

How do I override this message or show my own message.

 

public class wrap2co {
String searchSolutionText;
List<List<sObject>> tresults;
List<Solution> results;

public String getSearchSolutionText() {
return searchSolutionText;
}

public void setSearchSolutionText(String s) {
searchSolutionText = s;
}

public List<Solution> getResults() {
return results;
}

public PageReference doSearch() {
tresults = [FIND :searchSolutionText RETURNING Solution(SolutionName, SolutionNote, CreatedDate)];
results = (List<Solution>)tresults[0];
return null;
}
}

 

<apex:page controller="wrap2co">
<script LANGUAGE="JavaScript1.2" TYPE="text/javascript">
function unloadMessage(){
message = "Wait! You haven't finished."
return message;
}
function setBunload(on){
window.onbeforeunload = (on)? unloadMessage : null;


}
setBunload(true);
</script>
<apex:form >
<apex:pageBlock >
<apex:pageblockButtons >
<apex:commandButton action="{!doSearch}" value="Search" rerender="output"></apex:commandButton>
</apex:pageblockButtons>
<apex:inputText value="{!SearchSolutionText}"></apex:inputText>
</apex:pageBlock>
<apex:outputPanel >
<apex:pageBlock >
<apex:pageblockTable value="{!results}" var="v">
<apex:column value="{!v.SolutionName}"/>
<apex:column value="{!v.SolutionNote}"/>
<apex:column value="{!v.CreatedDate}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
</apex:page>

 

 

Thanks,

Trick

Hi Friends,

 

My scenario is such that only when customer logs into the portal then tab on the portal should become visible.if he is not logged in then it should not become visible to the customer.   Any idea on how we can do this.Some attributes or something else.

Any info or any example on this is highly welcome.If u can point to any link which can help me in accomplisihing this will be great.

 

Thanks,

Trick

 

Hi Friends, I want to create a tab on the customer portal and underneath I want to have iframe and in that I want to display website.Tab on the portal will not be an existing tab of salesforce .I want to create a new tab on the portal not that I want to expose existing tab such as account or contact from salesforce. What do u think is going to be the best way to do it.Any suggestions or inputs are most welcome. Thanks, Trick
  • June 07, 2012
  • Like
  • 0

Hi Guys,

 

 

Can we host flex application in salesforce.If not why ,Can somebody answer.

 

Thanks,

Chinglish

Hi Friends,

 

Can we assign events to calendars in salesforce and make it vsible on the calendar.Quick response will be greatly appreciated.

 

 

Thanks,

Trick

Hi Friends, 

 

I want to create PDF file from the record of an event object.Does anyone know how to go about it? 

 

If there is some example of how they have done it?    

Thanks, 

Trick

  • May 07, 2012
  • Like
  • 0

Hi Friends,

 

Consumer Key
Consumer Secret

I need to know,for example, when I register some website in the remote setting in salesforce in order to make callouts.
Consumer Key means what Does it belongs to salesforce or the website which was registered in salesforce.


Is it same about consumer secret.
Can somebody please explain with an example ?.

 

Thanks

Trick

  • March 29, 2012
  • Like
  • 0

Hi Friends,

 

I have customer portal and on that portal I have link which should take me to the another web site

side

 

Scenario:-

 

If somebody is on the customer portal and he is logged in the portal and then clicks on the link.It should be verified whether the customer has been logged in and if he is  then he should be taken to another website without having to log into the web site.

 

Can somebody please tell me how to go about it.Please guide me in the right direction by giving me a start.

 

Basically integrating one website with another web site.

 

Thanks,

Trick

 

 

 

 

 

 

 

 

  • March 26, 2012
  • Like
  • 0

Hi Friends,

 

I have input text field and search button next to the field. I want to generate soql query in the controller class function.

When somebody enters something in the input  field and click  on the search field  it should assign that value to the Soql statements where clause .It should looks something like this.

database.query(select id,name from account where name=What should I be doing there And how to do that);

 

I knoe I have to use setter method but How do I link inputetxt field and pass its value to the soql query.

 

Please help.

 

Trick

 

SELECT Id, Name
FROM Account
WHERE Name = 'Sandy
  • March 12, 2012
  • Like
  • 0

Hi

 

I have a trigger OpenActivityCount to get the count of the open tasks created on the open activity related list. The count of the tasks appear on the No. of Open Activities field.

 

I am getting a problem here.

 

The issue is all the new tasks created after I have deployed the tigger are getting populated in the field whereas the older tasks are not being populated. I want the total count of the open tasks in the field before and after I have deployed the trigger.

 

Can anyone please tell me how to overcome this issue.

 

This is the trigger

 

trigger OpenActivityCount on Task(after insert,after update)
{
if(trigger.new[0].AccountId!=null)
{
Account ac=[select id, No_of_Open_Activities__c from Account where id=:trigger.new[0].AccountId];
if(ac!=null)
{
if(ac.No_of_Open_Activities__c == null)
ac.No_of_Open_Activities__c =0;
if(trigger.isinsert) {
if(trigger.new[0].status!='Completed') {
ac.No_of_Open_Activities__c +=1;
}
}

if(trigger.isupdate )
{
if(trigger.new[0].status == 'Completed')
ac.No_of_Open_Activities__c -= 0.5;
if(trigger.new[0].status != 'Completed')
ac.No_of_Open_Activities__c += 0.5;
}

update ac;
}
}
}

 

  • February 29, 2012
  • Like
  • 0

Hi Friends,

 

When we buy web services from websites such as strikeiron etc then in the stub classes we have to specify user name and pasword.

 

 

My question is how do we get that username and password.?.Is there a way to generate?

 

Please help.

 

Thanks,

Trick

  • February 26, 2012
  • Like
  • 0
I am writing some APEX callouts to call webservice on our company network,  I want to restrict access to these webservice only allow the Salesforce IP address, but I can't find the IP address ranges I should use.  Can anyone help me?
 
Thanks