• svernon
  • NEWBIE
  • 0 Points
  • Member since 2013

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

I"m trying to create a custom button on a case (attached to an opportunity), to add over the contact roles which are associated to that oppty to the case. Here's the code I have but I'm not sure how to amend it to work for all contact roles and not just the primary.

 

{!requireScript("/soap/ajax/19.0/connection.js")}

function getBaseURL() {
//This function will return the base part of the current window's URL without the trailing slash.
//Example Return Value: "https://na1.salesforce.com"

	var fullURL = window.parent.location.href;
	var slashPosition = fullURL.indexOf("/", 9);
	var baseURL;
	
	if (slashPosition < 0)
		baseURL = fullURL;
	else
		baseURL = fullURL.substr(0, slashPosition);
		
	return baseURL;
}

function doQuery() {
	var result = sforce.connection.query("select Id, OpportunityId, ContactId, Role, IsPrimary from OpportunityContactRole where OpportunityId = '{!opportunity.id}' and IsPrimary = true");
	var records = result.getArray("records");

	if (records.length > 0)
		window.parent.location.href = getBaseURL() + "/_ui/core/email/author/EmailAuthor?p2_lkid=" + records[0].ContactId + "&rtype=003&p3_lkid={!opportunity.id}&retURL=%2F{!opportunity.id}";
	else
		if (confirm("ERROR: There is no Primary Contact specified yet for this opportunity. Click OK to specify one now."))
			window.parent.location.href = getBaseURL() + "/p/opp/ContactRoleEditUi/e?oppid={!opportunity.id}&retURL=%2F{!opportunity.id}";
}

doQuery();

I can't seem to get the survey force app I installed public site url to work. I installed the app with permissions for all users not just admins, then followed the directions in the guide (enabled site visualforce pages labs survey css and take survey), I also edited the public access object settings as specified. But, when I to create survey, then select the the sharing settings email link w/anonymous and select the surveys site, the url I receive brings up the under construction page.

 

I'm working in the sandbox environment--not sure if this matters?