• withoutme
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 26
    Questions
  • 33
    Replies

We have a custom object (NSP) that has a look up field to an opportunity. I would like to query the opportunity object but also determine if the opp has any NSPs attached to it. I can build out the query with the force.com IDE but this is what I get:

 

 

select Id, (Select Id, Name From R00N50000001gFM3EAM limit 1) from Opportunity

It seems a little bizarre the relationship name is a pseudo ID. I would rather not have to hard code this value if possible. Any one have ideas?

 

Thanks,

Jason

 

 

Hey
I have a custom VF button in my Campaign Detail page. This button queries the Campaign members and generates a pdf document (list of members and there submissions).

Depending on the campaign member record type selected, i want to generate a different list - Survey, Webcast etc etc.

How do I pass the CampaignMemberRecordTypeId from campaign detail page to the VF page?

Doing     Campaign cap = [select Id, CampaignMemberRecordTypeId from Campaign where id = :campid];

only gives an error saying "CampaignMemberRecordTypeID" - No such Column? 


 

Also, I need to be able to compare the above campaignmemberrecordtypeid with the specified record type ids for campaign member. So I did this
Schema.SObjectType.CampaignMember.getRecordTypeInfosByName().get('Survey').getRecordTypeId()

only to get null. What am I doing wrong?
-VJ

Message Edited by withoutme on 01-24-2010 11:07 PM

If List<Id> cid is a list of contact Id, I want to get a list of tasks associated with these contacts, but only 1 per contact Id.

Doing

[select t.Status, t.Type, t.WhoId from Task t where (t.WhoId in :cid and (t.type ='Call Completed - With Relevant Contact')) Limit 1] 

returns a total of only 1 task record. I want it to return one for each contact. Is this possible? Thank you 

Is it possible to embed a VF page at the top of a create new page? I want to add the funtionality of checking for dupes during the process of entering contact info. Overriding the new button doesnt work as I have to recreate the entire create new page from scratch for this to work (I do dupe check using First Name, Last Name, Email and Account)

Thanks

-VJ 

Hi All

We have a huge issue of duplicates. So I'm creating a contact dupe check VF page. Whenever the user clicks on New, the user has to be directed to this dupe check page, where in after a search, he either skips entering a contact, or continues to the actual create new contact page.

 

I have created the Dupe Check Page (below) with an extension. Now I want to be able to direct the user to the create new page when he clicks continue. I'm unable to understand how to do this. The problem is

 

1. When I replace the New button . On Clicking New, SF takes me to the record type selection page. And then the VF page. Now how do I save the recordtype that the user selected?

 

2. When I click on continue, how do I pass the parameters - First Name, Last Name, Email, Account Name, Record type to the create new page? And most importantly how do I go to the actual create New page?

Any help will be greatly appreciated. Thank you. 

 

<apex:page standardController="Contact" extensions="ContactDupeCheck"><apex:form >

<apex:pageBlock title="Quick Dupe Check">

<apex:pageBlockSection columns="2">

<apex:pageBlockSectionItem >

<apex:outputLabel value="First Name" for="fname"/>

<apex:inputtext value="{!fName}" id="fname"/>

</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >

<apex:outputLabel value="Last Name" for="lname"/>

 

<apex:inputText value="{!lName}" id="lname"/>

</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >

<apex:outputLabel value="Email" for="email"/>

<apex:inputtext value="{!eemail}" id="email"/>

</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >  

<apex:outputLabel value="Account Name" for="accName"/>  

<apex:inputText value="{!aname}" id="accname"/> 

</apex:pageBlockSectionItem>  

</apex:pageBlockSection>  

<apex:commandButton action="{!dupecheck}" value="Find Dupes" rerender="listing" status="status">

<apex:actionSupport event="onchange" rerender="listing"/></apex:commandButton>

<apex:actionstatus id="status" startText="processing...">

<apex:facet name="stop"></apex:facet> </apex:actionstatus>

</apex:pageBlock>

<apex:pageBlock title="Possible Dupes" >

<apex:pageBlockSection id="listing" columns="1">

<apex:pageBlockTable rows="10" value="{!conList}" var="c" border="0" cellspacing="0" cellpadding="10">

<apex:column ><a href = "/{!c.Id}">Click Here</a></apex:column>

<apex:column value="{!c.FirstName}"/>

<apex:column value="{!c.LastName}"/>

<apex:column value="{!c.Email}"/>  

<apex:column value="{!c.Title}"/>  

<apex:column value="{!c.AccountId}"/>  

<apex:column value="{!c.Account.Account_Manager__c}"/>  

<apex:column value="{!c.Account.NBR__c}"/>  

<apex:column value="{!c.Account.Territory__c}"/>  

<apex:column value="{!c.Account.OwnerId}"/>  

</apex:pageBlockTable>  

</apex:pageBlockSection>  

<apex:commandButton action="{!cancel}" value="Cancel"></apex:commandButton>

<apex:commandButton action="{!add}" value="Continue"></apex:commandButton>

</apex:pageBlock>

</apex:form>

</apex:page>

 

 

---Extension

 

 

public without sharing class ContactDupeCheck {

private final Contact cont;

public ContactDupeCheck(ApexPages.StandardController controller){

this.cont = (Contact)controller.getRecord();

}

Public List<Contact> conList = new List<Contact>();

public List<Contact> getConList(){

 

return conList;

}

public void setConList(List<Contact> conList){

this.conList = conList;

}

String aname;

public String getaname(){

 

return aname; }

public void setaname(String aname){

this.aname = aname;

}

String lname;

public String getlname(){

return lname;

}

 

public void setlname(String lname){

 

this.lname = lname;

}

String fname;

	public String getfname(){
		return fname;
	}
	public void setfname(String fname){
		this.fname = fname;
	}	
String eemail;	public String geteemail(){
		return eemail;	
}	public void seteemail(String eemail){
		this.eemail = eemail;	}	
public PageReference DupeCheck(){
		system.debug('IM IN');
		if(conList==null)
			conList = new List<Contact>();
		String querystring = 'select Id, FirstName, LastName, Title, AccountId, Email, Contact.Account.OwnerId, 						Contact.Account.Account_Manager__c, Contact.Account.NBR__c, Contact.Account.Territory__c from Contact where ';				String lnamefilter = 'LastName LIKE \'%' + String.escapeSingleQuotes(lName) + '%\'';		
		String emailfilter = 'Email LIKE \'%' + String.escapeSingleQuotes(eemail) + '%\'';		
		String fnamefilter = 'FirstName LIKE \'%' + String.escapeSingleQuotes(fName) + '%\'';		
		String anamefilter = ' Contact.Account.Name Like \'%' + String.escapeSingleQuotes(aname) + '%\'';		
		String conqstring  = querystring;		
		Set<Id> cids = new Set<Id>();		
		if(eEmail.length()!=0){			
			System.debug('IN E');			
			conqstring+=emailfilter;			
			conList = Database.query(conqstring);			
			for(Contact c :conList)				
			cids.add(c.Id);		}			
	if(aname.length()!=0 && lName.length()!=0 && fName.length()!=0){
			System.debug('IN A');			
			querystring+=anamefilter+' and '+ lnamefilter+' and ' + fnamefilter;
			for(Contact c :Database.query(querystring)){
				if(!cids.contains(c.Id)){
					conList.add(c);	
				cids.add(c.Id);		
		}	
		}		
}		
else{			
		System.debug('IN N');			
		if(lName.length()!=0 && fName.length()!=0){
				querystring+=lnamefilter + ' and ' + fnamefilter;
				for(Contact c :Database.query(querystring))
					if(!cids.contains(c.Id)){
					conList.add(c);	
				cids.add(c.Id);	
 
}			
}		
}								
		System.debug('FINAL QUERY STRING'+querystring);				
return null;	
}	
public PageReference add(){
		//PageReference rtpage = new PageReference();		
	Map<String,String> BaseURL = ApexPages.currentPage().getHeaders();
		for(String s :BaseUrl.keyset())			
System.debug('BaseUrl::::::::'+BaseUrl.get(s));		
return null;	

} 

 

 

Message Edited by withoutme on 07-30-2009 02:25 AM
Message Edited by withoutme on 07-30-2009 02:30 AM

I manage account sharing using APEX (accountshare table). If that user is specified in the lookup (Account manager) he is given access to that account(and related contact and opportunities). But, the problem is when the account is part of a tree. Likethis

                       A

                                    |

______________

|             |                

B C

_____________

| | |

D E

 

So if a user is specified in the manager lookup in account E, I need to make sure he has full access to the entire tree:A.B.C.D.E.F. I have seen that giving the user access to A does not give him access to accounts lower down in the heirarchy automatically.

 

Any ideas?

I manage account sharing using APEX (accountshare table). If that user is specified in the lookup (Account manager) he is given access to that account(and related contact and opportunities). But, the problem is when the account is part of a tree. Likethis

                       A

                                    |

______________

|            |                

B C

_____________

| | |

D E

 

So if a user is specified in the manager lookup in account E, I need to make sure he has full access to the entire tree:A.B.C.D.E.F. I have seen that giving the user access to A does not give him access to accounts lower down in the heirarchy automatically.

 

Any ideas? 

 

Are account teams (and sales teams) available to be manipulated using apex triggers (create, edit, delete...). Any help will be greatly appreciated. Thank you

-Vj 

As an administrator, how do I get a list of all the reports that are scheduled to be run and emailed to diff users?

I need, report name, schedule time and user being emailed to.

Please help. Thank you

-Vj 

Hello All,

 

I need to share Leads/Accounts/Contacts and Opportunities to individuals who are specified in two diff lookup fields in each record. I'm looking at how this can be accomplished - automatically - auto share!!

 

1. Account teams: This is the best I guess as we use salesforce built in functionality. And each record can have its own account team. Right? But I want to automate this. Like on save of an account record,  i want the team to eb created and automatically the record be shared. I need to write an apex trigger to do this? But Apex Managed Sharing is only available for custom objects according the the apex language reference. (pg 139).

But I have seen that all std objects have an object called AccountShare (instead of customobj_share objects for custom). Can I use this to programmtically assign sharing? if so how? Any examples? But how is this different from apex managed sharing?

 

2. For opportunities, i use Sales teams?

3. What abt leads?

 

Any inputs will be greatly appreciated. Thank you

-Vj

I have a custom button which renders a pdf page using visualforce. But the page needs to have a custom top/bottom/left/right margin (like 3mm). I know I need to use stylesheets, but I really dont know anything abt style sheets. Can someone help me please?

1. First - is it better to specify the style sheet as a static resource or directly in the vf page?.

 

2. I need to declare the style sheet after the <apex:page> tags right? but then I have to render the page itself with the margins specified in the style sheets. Will the style sheet take effect, even when it is specified after the <apex:page renderas="pdf"> tag?

 

3. How do I write the style? I'm a noivce when it comes to styles. Please help.

 

Thank you 

Can org. wide defaults, sharing rules, profiles, lead assignment rules be moved from sandbox to production? if so how? Please help. Thank you

I have a requirement where when the Lead reaches a certain stage, I want to merge a custom field(coupon code) with a .doc, convert to pdf and mail it in? is this possible? Please keep in mind that the .doc is a flyer with images. So rendering a page in VF may not work. This process needs to be automated. Say, I figure out how to generate a pdf, but I cannot set attachments in my workflow email alert. Do I need to use apex outbound email?

 

 

Thanks for the help

 

Message Edited by withoutme on 06-04-2009 10:07 AM

I am modifiying an old php form which post's data to a sql database and also emails the same  - with webtolead coding.

The web-to-lead part works great - all leads come into to salesforce without any problems. But now the insert to sql database and email out stopped working.

 

I think the problem is when I assign local variable with the $_POST data. Is it ok to do something like this for a custom field

 

$eveningphone = $_POST['00N80000003a4s'];

 

Can I assign the 18digit salesforce ID in this way? 

Couple of questions regarding web 2 case

 

1. Do web 2 case forms support populating lookup fields? If not, what is the workaround?

 

2. Can web 2 case forms on submission, "update" an existing record instead of inserting? I guess this can be done using a trigger which query's all cases - finds a match - updates. Is this possible? Any other way?

 

3. For above, can I pass record ID to the web2case form using a link(with hidden field in the form for the record ID), this way I don't have to query ?

 

Thanks you for any help. 

I have a requirement where web2leads need to be automatically converted.

 

So

1. I have a before update trigger that takes the lead and assigns lead owners depending on the workload. (Round robin assignment)

2. after update trigger that uses the convertLead() method to convert the lead.

 

The debug log says the conversion result is true (look below) and even gives me the IDs of the account, contact and opportunities. however, these records are NO WHERE to be found. Appending the IDs to the instances like https://na5.salesforce.com/00Q7000000QNZjwEAH only results in 

"

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"

 

0090505071239.525:Class.w2l.convld: line 14, column 42:     DML Operation executed in 2132 ms20090505071239.525:Class.w2l.convld: line 15, column 9: CONVERSION RESULT IS::::Database.LeadConvertResult[getAccountId=0017000000Wl66SAAR;getContactId=0037000000fSu8CAAS;getErrors=();getLeadId=00Q7000000QNZjwEAH;getOpportunityId=0067000000G0rGQAAZ;isSuccess=true;]20090505071239.525:Class.w2l.convld: line 23, column 28: SOQL query with 1 row finished in 5 ms20090505071239.525:Class.w2l.convld: line 24, column 9: CONVERTED OPPORTUNITY ISOpportunity:{RecordTypeId=0127000000016bhAAA, Id=0067000000G0rGQAAZ}20090505071239.525:Trigger.autoconvertW2L: line 6, column 21:     returning from end of method public static void convld(SOBJECT:Lead) in 2146 ms20090505071239.525:Trigger.autoconvertW2L: line 7, column 17: IM BACK FROM CONVERSION20090505071239.525:Trigger.autoconvertW2L: line 11, column 9: CONVERION COMPLETE

 

 Searching in the search bar = no result. Where are my records??? What am I missing?

 

FYI. Creating new leads thru the UI and setting the custom piclist to web2 lead, works flawlessly. Ownerships is update and lead is auto converted on save. Its when the lead comes from web, that this happens. 

Message Edited by withoutme on 05-05-2009 01:09 AM

Salesforce automatically emails the sys admin whenever a exception error or someother error occurs.

1. Is there a way to make salesforce email the debug log to more than one person?

2. Is there a way  to make salesforce email the debug log when a certain trigger or apex class is fired? 

How do I specify the name,value for email headers in my test method for inbound email services?

Messaging.InboundEmail.Header[] hd = email.headers[name='Date', value='Tue, 28 Apr 2009 14:08:37 -0700']; THIS GIVES AN ERROR Messaging.InboundEmail.Header[] hd = email.headers; hd[0].name='Date'; hd[0].value='Tue, 28 Apr 2009 14:08:37 -0700']; THIS GIVES SYSTEM.NULLPOINTEREXCEPTION ERROR

 Any help will be greatly appreciated

Is there a way to attach logos and company information to exported reports automatically?

How would I remove the salesforce.com footer in the generated report?

Since customer portals doesnt have a opportunity tab and has security to not edit opportuities, how would I let my customer VIEW there opportunities?

Will a VF page work? with restrictions? Would I have to make a VF tab - detail page? But then wat happens to the standard actions(edit, save, canel) and there buttons in a customer portal? disabled? invisible?

In opportunitues, you have a "clone with Products" and a "clone without products".

This creates a new opportunity with the same opp and products data.

 

What if I want to clone button, but the result is another custom object (invoice) with "opp clone with products" as the details.

 

How would I go abt doing this?

1. Create the invoice custom object with all opp fields. Can I set products as detail of invoice so that I can copy the products too?

2. Create a vf page with extension of opportunity standard controller. In the extension, how do I get the process the clone logic?

 

Please help. Thank you

If List<Id> cid is a list of contact Id, I want to get a list of tasks associated with these contacts, but only 1 per contact Id.

Doing

[select t.Status, t.Type, t.WhoId from Task t where (t.WhoId in :cid and (t.type ='Call Completed - With Relevant Contact')) Limit 1] 

returns a total of only 1 task record. I want it to return one for each contact. Is this possible? Thank you 

Hi All

We have a huge issue of duplicates. So I'm creating a contact dupe check VF page. Whenever the user clicks on New, the user has to be directed to this dupe check page, where in after a search, he either skips entering a contact, or continues to the actual create new contact page.

 

I have created the Dupe Check Page (below) with an extension. Now I want to be able to direct the user to the create new page when he clicks continue. I'm unable to understand how to do this. The problem is

 

1. When I replace the New button . On Clicking New, SF takes me to the record type selection page. And then the VF page. Now how do I save the recordtype that the user selected?

 

2. When I click on continue, how do I pass the parameters - First Name, Last Name, Email, Account Name, Record type to the create new page? And most importantly how do I go to the actual create New page?

Any help will be greatly appreciated. Thank you. 

 

<apex:page standardController="Contact" extensions="ContactDupeCheck"><apex:form >

<apex:pageBlock title="Quick Dupe Check">

<apex:pageBlockSection columns="2">

<apex:pageBlockSectionItem >

<apex:outputLabel value="First Name" for="fname"/>

<apex:inputtext value="{!fName}" id="fname"/>

</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >

<apex:outputLabel value="Last Name" for="lname"/>

 

<apex:inputText value="{!lName}" id="lname"/>

</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >

<apex:outputLabel value="Email" for="email"/>

<apex:inputtext value="{!eemail}" id="email"/>

</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >  

<apex:outputLabel value="Account Name" for="accName"/>  

<apex:inputText value="{!aname}" id="accname"/> 

</apex:pageBlockSectionItem>  

</apex:pageBlockSection>  

<apex:commandButton action="{!dupecheck}" value="Find Dupes" rerender="listing" status="status">

<apex:actionSupport event="onchange" rerender="listing"/></apex:commandButton>

<apex:actionstatus id="status" startText="processing...">

<apex:facet name="stop"></apex:facet> </apex:actionstatus>

</apex:pageBlock>

<apex:pageBlock title="Possible Dupes" >

<apex:pageBlockSection id="listing" columns="1">

<apex:pageBlockTable rows="10" value="{!conList}" var="c" border="0" cellspacing="0" cellpadding="10">

<apex:column ><a href = "/{!c.Id}">Click Here</a></apex:column>

<apex:column value="{!c.FirstName}"/>

<apex:column value="{!c.LastName}"/>

<apex:column value="{!c.Email}"/>  

<apex:column value="{!c.Title}"/>  

<apex:column value="{!c.AccountId}"/>  

<apex:column value="{!c.Account.Account_Manager__c}"/>  

<apex:column value="{!c.Account.NBR__c}"/>  

<apex:column value="{!c.Account.Territory__c}"/>  

<apex:column value="{!c.Account.OwnerId}"/>  

</apex:pageBlockTable>  

</apex:pageBlockSection>  

<apex:commandButton action="{!cancel}" value="Cancel"></apex:commandButton>

<apex:commandButton action="{!add}" value="Continue"></apex:commandButton>

</apex:pageBlock>

</apex:form>

</apex:page>

 

 

---Extension

 

 

public without sharing class ContactDupeCheck {

private final Contact cont;

public ContactDupeCheck(ApexPages.StandardController controller){

this.cont = (Contact)controller.getRecord();

}

Public List<Contact> conList = new List<Contact>();

public List<Contact> getConList(){

 

return conList;

}

public void setConList(List<Contact> conList){

this.conList = conList;

}

String aname;

public String getaname(){

 

return aname; }

public void setaname(String aname){

this.aname = aname;

}

String lname;

public String getlname(){

return lname;

}

 

public void setlname(String lname){

 

this.lname = lname;

}

String fname;

	public String getfname(){
		return fname;
	}
	public void setfname(String fname){
		this.fname = fname;
	}	
String eemail;	public String geteemail(){
		return eemail;	
}	public void seteemail(String eemail){
		this.eemail = eemail;	}	
public PageReference DupeCheck(){
		system.debug('IM IN');
		if(conList==null)
			conList = new List<Contact>();
		String querystring = 'select Id, FirstName, LastName, Title, AccountId, Email, Contact.Account.OwnerId, 						Contact.Account.Account_Manager__c, Contact.Account.NBR__c, Contact.Account.Territory__c from Contact where ';				String lnamefilter = 'LastName LIKE \'%' + String.escapeSingleQuotes(lName) + '%\'';		
		String emailfilter = 'Email LIKE \'%' + String.escapeSingleQuotes(eemail) + '%\'';		
		String fnamefilter = 'FirstName LIKE \'%' + String.escapeSingleQuotes(fName) + '%\'';		
		String anamefilter = ' Contact.Account.Name Like \'%' + String.escapeSingleQuotes(aname) + '%\'';		
		String conqstring  = querystring;		
		Set<Id> cids = new Set<Id>();		
		if(eEmail.length()!=0){			
			System.debug('IN E');			
			conqstring+=emailfilter;			
			conList = Database.query(conqstring);			
			for(Contact c :conList)				
			cids.add(c.Id);		}			
	if(aname.length()!=0 && lName.length()!=0 && fName.length()!=0){
			System.debug('IN A');			
			querystring+=anamefilter+' and '+ lnamefilter+' and ' + fnamefilter;
			for(Contact c :Database.query(querystring)){
				if(!cids.contains(c.Id)){
					conList.add(c);	
				cids.add(c.Id);		
		}	
		}		
}		
else{			
		System.debug('IN N');			
		if(lName.length()!=0 && fName.length()!=0){
				querystring+=lnamefilter + ' and ' + fnamefilter;
				for(Contact c :Database.query(querystring))
					if(!cids.contains(c.Id)){
					conList.add(c);	
				cids.add(c.Id);	
 
}			
}		
}								
		System.debug('FINAL QUERY STRING'+querystring);				
return null;	
}	
public PageReference add(){
		//PageReference rtpage = new PageReference();		
	Map<String,String> BaseURL = ApexPages.currentPage().getHeaders();
		for(String s :BaseUrl.keyset())			
System.debug('BaseUrl::::::::'+BaseUrl.get(s));		
return null;	

} 

 

 

Message Edited by withoutme on 07-30-2009 02:25 AM
Message Edited by withoutme on 07-30-2009 02:30 AM

I manage account sharing using APEX (accountshare table). If that user is specified in the lookup (Account manager) he is given access to that account(and related contact and opportunities). But, the problem is when the account is part of a tree. Likethis

                       A

                                    |

______________

|            |                

B C

_____________

| | |

D E

 

So if a user is specified in the manager lookup in account E, I need to make sure he has full access to the entire tree:A.B.C.D.E.F. I have seen that giving the user access to A does not give him access to accounts lower down in the heirarchy automatically.

 

Any ideas? 

 

Are account teams (and sales teams) available to be manipulated using apex triggers (create, edit, delete...). Any help will be greatly appreciated. Thank you

-Vj 

As an administrator, how do I get a list of all the reports that are scheduled to be run and emailed to diff users?

I need, report name, schedule time and user being emailed to.

Please help. Thank you

-Vj 

Can org. wide defaults, sharing rules, profiles, lead assignment rules be moved from sandbox to production? if so how? Please help. Thank you

I am modifiying an old php form which post's data to a sql database and also emails the same  - with webtolead coding.

The web-to-lead part works great - all leads come into to salesforce without any problems. But now the insert to sql database and email out stopped working.

 

I think the problem is when I assign local variable with the $_POST data. Is it ok to do something like this for a custom field

 

$eveningphone = $_POST['00N80000003a4s'];

 

Can I assign the 18digit salesforce ID in this way? 

Couple of questions regarding web 2 case

 

1. Do web 2 case forms support populating lookup fields? If not, what is the workaround?

 

2. Can web 2 case forms on submission, "update" an existing record instead of inserting? I guess this can be done using a trigger which query's all cases - finds a match - updates. Is this possible? Any other way?

 

3. For above, can I pass record ID to the web2case form using a link(with hidden field in the form for the record ID), this way I don't have to query ?

 

Thanks you for any help. 

We have a custom object (NSP) that has a look up field to an opportunity. I would like to query the opportunity object but also determine if the opp has any NSPs attached to it. I can build out the query with the force.com IDE but this is what I get:

 

 

select Id, (Select Id, Name From R00N50000001gFM3EAM limit 1) from Opportunity

It seems a little bizarre the relationship name is a pseudo ID. I would rather not have to hard code this value if possible. Any one have ideas?

 

Thanks,

Jason

 

 

Note : Following is a small development being carried out to demystify salesforce apex webservice and callout features, please correct me if you find my understanding to be incorrect.

 

I am trying to integrate two Salesforce Orgs using Apex. Apex supports both callouts and webservices, then why not leverage both to achieve a 360 connectivity between two Salesforce instances.

 

Org1 : Create a Apex Web Service, Generate its WSDL

global class AccountPlan {

webservice String area;
webservice String region;

//Define an object in apex that is exposed in apex web service
global class Plan {
webservice String name;
webservice Integer planNumber;
webservice Date planningPeriod;
webservice Id planId;
}

webservice static Plan createAccountPlan(Plan vPlan) {

//A plan maps to the Account object in salesforce.com.
//So need to map the Plan class object to Account standard object
Account acct = new Account();
acct.Name = vPlan.name;
acct.AccountNumber = String.valueOf(vPlan.planNumber);
insert acct;

vPlan.planId=acct.Id;
return vPlan;
}

}

 

Org2:  Consume above generated WSDL to generate following Apex Class viz.,AccountPlanClasses

public class AccountPlanClasses {
public class LogInfo {
public String category;
public String level;
private String[] category_type_info = new String[]{'category','http://soap.sforce.com/schemas/class/TCSSAAS/AccountPlan','LogCategory','1','1','false'};
private String[] level_type_info = new String[]{'level','http://soap.sforce.com/schemas/class/TCSSAAS/AccountPlan','LogCategoryLevel','1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/TCSSAAS/AccountPlan','true','false'};
private String[] field_order_type_info = new String[]{'category','level'};
}
public class AllowFieldTruncationHeader_element {
............................
............................

 

Now lets try to connect to Org1 from Org2

AccountPlanClasses.Plan plan = new AccountPlanClasses.Plan();
plan.name = 'Chirag';
plan.planNumber = 111;
AccountPlanClasses.AccountPlan a = new AccountPlanClasses.AccountPlan();
a.createAccountPlan(plan);

 

Execution of above code runs into following error

WebService returned a SOAP Fault: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session faultcode=sf:INVALID_SESSION_ID faultactor= 

 

I to feel that somewhere I am missing User Credentials to be supplied, but I dont know exactly where. Please guide me to complete this 360 connectivity between two orgs using Apex.

Message Edited by Chirag Mehta on 05-05-2009 06:13 AM
Message Edited by Chirag Mehta on 05-12-2009 07:52 PM

I have a requirement where web2leads need to be automatically converted.

 

So

1. I have a before update trigger that takes the lead and assigns lead owners depending on the workload. (Round robin assignment)

2. after update trigger that uses the convertLead() method to convert the lead.

 

The debug log says the conversion result is true (look below) and even gives me the IDs of the account, contact and opportunities. however, these records are NO WHERE to be found. Appending the IDs to the instances like https://na5.salesforce.com/00Q7000000QNZjwEAH only results in 

"

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"

 

0090505071239.525:Class.w2l.convld: line 14, column 42:     DML Operation executed in 2132 ms20090505071239.525:Class.w2l.convld: line 15, column 9: CONVERSION RESULT IS::::Database.LeadConvertResult[getAccountId=0017000000Wl66SAAR;getContactId=0037000000fSu8CAAS;getErrors=();getLeadId=00Q7000000QNZjwEAH;getOpportunityId=0067000000G0rGQAAZ;isSuccess=true;]20090505071239.525:Class.w2l.convld: line 23, column 28: SOQL query with 1 row finished in 5 ms20090505071239.525:Class.w2l.convld: line 24, column 9: CONVERTED OPPORTUNITY ISOpportunity:{RecordTypeId=0127000000016bhAAA, Id=0067000000G0rGQAAZ}20090505071239.525:Trigger.autoconvertW2L: line 6, column 21:     returning from end of method public static void convld(SOBJECT:Lead) in 2146 ms20090505071239.525:Trigger.autoconvertW2L: line 7, column 17: IM BACK FROM CONVERSION20090505071239.525:Trigger.autoconvertW2L: line 11, column 9: CONVERION COMPLETE

 

 Searching in the search bar = no result. Where are my records??? What am I missing?

 

FYI. Creating new leads thru the UI and setting the custom piclist to web2 lead, works flawlessly. Ownerships is update and lead is auto converted on save. Its when the lead comes from web, that this happens. 

Message Edited by withoutme on 05-05-2009 01:09 AM

Hello all,

 

I have an Apex trigger attached to lead creation which currently works as intended in sandbox when I use the "New" button in the Lead area. My system.debug output works correctly when using the System Log pop-up.

 

With that, my next step was to test the Web-to-Lead creation to assure that the trigger was also working there. The leads are being created, however the trigger does not seem to be firing at all and I am getting no response in the Monitoring > Debug Logs area to see what the issues may be. I have used "Add Users To Debug Logs" to assure that I am requesting the logs, which is working when I create a Lead from within the sandbox.

 

Based on what I've seen on our Debug Log in production, I believe I should be seeing Request Type = "Application", Application = "Browser" and Operation = "Async Metadata" (along with a boatload of other API calls).

 

I know that the Web-to-Lead HTML has the option to turn on debug mode, so I did that, but I don't think it's the same debugging I need.

 

Any help is appreciated, thank you.

   

 

  • April 20, 2009
  • Like
  • 0

A few years ago I saw a demo where a customer merged the Lead ID into to append to a URL in an email template. The URL pointed the email recipient to a web to lead form which had the Lead ID pre-populated from the merged Lead ID field contained in the URL. By doing this, the customer was able to send out event registrations to existing Leads and have them register for the event (Campaign) via a web to lead form without needing to provide information which they had previously provided.

 

I can setup the email template to include the merge field, however can't work out how to get the lead ID field on my web to lead form to populate. 

 

I thought the URL should look like this, although this just loads the web to lead form without inserting the Lead ID - http://www.<mywebsite>/html?Lead.Id=<lead record id>

 

Any suggestions?

Message Edited by WERD2 on 03-22-2009 04:36 AM
  • March 22, 2009
  • Like
  • 0
I'm trying to use the "renderAs" attribute, combined with a standard list controller to implement rudimentary mass mail merge capability. I've defined the following VF component:
 
Code:
<apex:component controller="DonationAcknowledgment">
    <apex:attribute name="donationId"
        description="The ID of the donation (Opportunity) to be acknowledged"
        type="String" required="true" assignTo="{!donationId}" />
    Dear {!Contact.Salutation} {!Contact.FirstName} {!Contact.LastName}, <br />
    <br />
    {!Organization.Name} would like to thank you for you generous
    donation of&nbsp;<apex:outputField value="{!Donation.Amount}" />. This email serves as your receipt
    for income tax reporting purposes. Please note that no goods or
    services have been provided in return for this donation. <br />
    <br />
    Sincerely, <br />
    {!User.Name} <br />
    {!User.Title} <br />
    {!User.CompanyName} <br />
    {!User.Street} <br />
    {!User.City} {!User.State} {!User.PostalCode} <br />
    Phone: {!User.Phone} <br />
    Email: {!User.Email}
</apex:component>

And the associated controller:
 
Code:
/* This class provides access to merge fields used to generate a donation acknowledgment letter */
public class DonationAcknowledgment {

    Opportunity o = null;
    Contact c = null;
    Account a = null;
    User u = null;
    Organization org = null;

    String donationId = null;
    
    public DonationAcknowledgment() { 
     System.debug('DonationAcknowledgment constructor called');
    }
    
    public String getDonationId() {
        return this.donationId;
    }
    
    public void setDonationId(String donationId) {
        System.debug('setDonation(' + donationId + ')');
        this.donationId = donationId;
    }

    /* Gets the Donation (Opportunity) object corresponding to the donation ID value */
    public Opportunity getDonation() {
     if (o == null) {
         o = [Select o.OwnerId, o.Name, o.IsClosed, o.Id, o.Description, o.CloseDate, o.Amount, o.AccountId,
            (Select ContactId, Role, IsPrimary From OpportunityContactRoles) 
            From Opportunity o Where o.Id = :donationId Limit 1];
     }
     System.debug('getDonation returning ' + o);
        return o;
    }
    
    public Contact getContact() {
     if (c == null) {
         Opportunity o = getDonation();
         String cId = o.OpportunityContactRoles[0].ContactId;
         c = [Select c.Title, c.Salutation, c.Phone, c.Name, c.MailingStreet, c.MailingState, c.MailingPostalCode,
            c.MailingCountry, c.MailingCity, c.LastName, c.Id, c.HomePhone, c.FirstName, c.Email, c.Description 
            From Contact c Where c.Id = :cId Limit 1];
     }
        return c;
    }
    
    public Account getAccount() {
     if (a == null) {
      Opportunity o = getDonation();
      String aId = o.AccountId;
      a = [Select a.Name, a.Id, a.BillingStreet, a.BillingState, a.BillingPostalCode, a.BillingCountry, a.BillingCity 
                From Account a Where a.Id = :aId Limit 1];
     }
     return a;
    }
    
    public Organization getOrganization() {
     if (org == null) {
      org = [Select o.Street, o.State, o.PrimaryContact, o.PostalCode, o.Phone, o.OrganizationType, 
        o.Name, o.Id, o.Fax, o.Division, o.Country, o.City From Organization o Limit 1];
     }
        return org;
    }
    
    public User getUser() {
     if (u == null) {
         String userId = UserInfo.getUserId();
         u = [Select u.Title, u.Street, u.State, u.PostalCode, u.Phone, u.Name, u.LastName, u.Id, u.FirstName, 
            u.Fax, u.Extension, u.EmployeeNumber, u.Email, u.Division, u.Country, u.CompanyName, u.City 
            From User u Where u.Id = :userId Limit 1];
     }
        return u;
    }
}

 
I then defined a VF page that uses the standard list controller for Opportunity objects as follows:
 
 
Code:
<apex:page standardController="Opportunity" recordSetVar="donations" renderAs="pdf" >
    <apex:repeat value="{!donations}" var="donation">
        <div style="page-break-after: always;">
            <c:donationAcknowledgment donationId="{!donation.Id}" />
        </div>
    </apex:repeat>
</apex:page>

 
This generates a multi-page PDF rendition, with each page populated with merge data, exactly the way I want it. The only issue is that this includes all Opportunity objects returned by the most recent view. What I really want to do is allow the user to select specific Opportunites. So, I modified my VF page as follows:
 
Code:
<apex:page standardController="Opportunity" recordSetVar="donations" renderAs="pdf" >
    <apex:repeat value="{!selected}" var="donation">
        <div style="page-break-after: always;">
            <c:donationAcknowledgment donationId="{!donation.Id}" />
        </div>
    </apex:repeat>
</apex:page>

 
I then created a custom list button and added it to the Opportunities list view. Now, when I try to generate the PDF rendition for several selected Opportunity objects, I get a blank PDF. For debugging purposes, I removed the renderAs attribute so my page would be rendered as HTML, and the page looks correct (meaning only the selected Opportunity objects were merged into the resulting HTML). Any ideas why the use of "{!selected}" is not when combined with renderAs="pdf"? Thanks in advance.
 
  • November 17, 2008
  • Like
  • 0