• finalist
  • NEWBIE
  • 105 Points
  • Member since 2006

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 40
    Questions
  • 76
    Replies

Hi Friends

 

I have using 4 custom objects such as contact , lead, Listing, closing . I have been removed  the new button on those custom object search layout page(Buttons displayed) . but these objects list view page has displayed new standard button. How to remove the standard new button from the custom objects list view page.?please post ur suggestion

 

 

Thanks

Sundar

I have a VF component that displays a blank inputfield that, when populated, retrieves the associated custom object record and displays additional data from that record.

 

When viewing the object in a detail page, all records & fields are visible to a particular profile; when I login as that user type, the fields and values are displayed.  When the visualforce page containing the custom component is loaded, the Label appears as an outputLabel, in the same pageBlock /  table as the inputField in question, but the inputfield is not visible at all to this profile. 

 

In the controller I create an empty Code_Map__c object, and then when the user clicks the 'Retrieve Code' button the Serial Number is passed in and the code associated to the Serial Number is displayed in a separate section.

 

While logged in as the user, again, the Serial Number field is displayed w/o an issue.   Any thoughts as to why the apex:inputfield would not show up at all to some profiles?

 

	<apex:pageBlock title="Retrieve Code" id="RetrieveCode">
		<table width="80%">
			<tr>
				<td>
					<apex:outputLabel value="{!$ObjectType.Code_Map__c.Fields.Serial_Number__c.Label}" for="serialNumber" />
				</td>
				<td>
					<apex:inputField id="serialNumber" value="{!cm.Serial_Number__c}" required="true" />
				</td>
			</tr>
			<tr>
				<td>
					<apex:commandButton action="{!fetchCode}" id="fetchCode" value="Retrieve Code" />
				</td>
			</tr>
		</table>
	</apex:pageBlock>

 

I've run into an odd scenario involving a cross-object validation that I'd like some fresh eyes on.  I want to prevent a Case from being created, updated or closed if the Case.Type is not in agreement with the associated Account's recordtype.

 

It sounds like a straightforward use case for a Validation Rule, but insert()s slip on through anyway (perhaps because Account.recordtypeId isn't available until after the Case is first saved..?  Guessing here.)  Updates and Case close are prevented, but that's not enough.

 

So I created a Case trigger (before insert, before update) that checks for Case.Type, creates a Set<Id> of Account Ids for the types I want to validate, retrieves the Account.Ids for the Account recordtypes I care about, and then uses addError() to flag those Cases that violate the rule.

 

i.e. Accounts of recordType 'X' must have Cases of Case.Type "Xtype", or I apply addError('Please use Case type "Xtype" when blah, blah blah');

 

The trigger works great, but is proving difficult to test:

 

#askForce pointed to a great example of Unit Testing for (presumably) an addError() use Testing Example

 

I create a Case with an invalid type, then attempt an insert() or update() using a try/catch block, then use the example to look at the exception - but no exception is thrown.

 

UI works great, though.

if (c.AccountId == a.Id && c.Type <> 'Xtype') {
	c.addError(' You must select a Case type of \'Critical Care\', as this is a Critical Care account.');
}

 

We've created a custom order object with values that roll-up to both Account and Contact via triggers.  Neither relationship (object > Contact, object > Account) is a master/detail.

We have code in place to cover scenarios if the contact's account changes, as the contact is the primary 'owner' of these custom orders, but as these come in from the web there are frequently duplicate Accounts that get created, and when the dupes are merged the rollups are not triggered.

An update on the Contact record will recalculate the rollups, but there doesn't seem to be an effective way to cause that update; at least, not in a way that's testable.

In the Account trigger we know which accounts were merged, as the 'losing' accounts are now populated with the winning account's Id in MasterRecordId, but it seems that no matter how we go about it, the Contact update never goes through because the Account trigger completes before the Contact update occurs, and the Contact still has a reference to the (now deleted) Account.

System.DmlException: Update failed. First exception on row 0 with id <contactId>; first error: ENTITY_IS_DELETED, entity is deleted:

I've tried using @future calls and creating a scheduled batch to run 10 seconds after the Account merge occurs, but none of these appear to be working.

Has anyone figured out how to handle merge() actions like this?  Do we have to create our own merge 

I ran into a problem last week when I was putting the finishing touches on a Schedulable Apex class, and I thought I'd pass the information along.  For those of you familiar with CronTrigger and System.abortJob(), you need not read further.

 

I had scheduled the job to run in the sandbox, and since the Client was also doing some testing I wanted to have as little downtime as possible while I made my updates.  My class names were fine, but I thought that the scheduled job's name could be more descriptive.  I deleted the job, saved my class changes and re-scheduled the job, unfortunately including an illegal/invalid character (' > ', in this case) in the job name.  The schedule took and the processing was fine, but when I tried to make a subsequent change to the class I couldn't delete the job!

 

Instead, I was getting an error related to 'page unavailable' and what appeared to be a reference to the job name having too many characters.

 

The upshot was that neither the Manage nor Delete links worked for the Scheduled Job, which meant that I could not save my changes because the batch was still running. It was time to delve into CronTrigger to delete the process from under the hood.

 

Using the schema query tool we were able to identify the job that was running (there was only one, and we could compare to the name listed under 'Monitoring / Scheduled Jobs')

 

 

Select c.State, c.StartTime, c.NextFireTime, c.Id, c.CronExpression, c.CreatedDate From CronTrigger c where ownerid = '<your user id, presumably>'


 With the Id from our query, we could then run

 

System.abortJob(<jobId>);

 and delete the process.

 

 

Just remember, Don' Panic (and always carry a towel.)

 

 

 

I have a single Contact enabled as a Contact Portal user, and created a login and password for that Contact.  Logging in as that user results in an error on my custom page (apparently): "Error: Error occurred while loading a Visualforce page."  No email was generated for the Administrator, though.

 

Is there a way to create a Debug Log for the Contact Portal user?  How can I identify what the VF error is, otherwise?

I am working in my dev org to allow access to a custom visualforce page through Sites.  The page displays a single Account and some related Custom Objects, and i made these accessible to the Guest User profile.  I was seeing the page but without details (though the Custom Controller is hard-coded to display a particular Account), so I decided to see what I could gain access to through using the Customer Portal.  The Customer Portal has access to even fewer objects than the Guest User (no custom objects at all), so that was a wrong move, but now although I deselected Login Enabled so that on the Sites detail page is reads 'Login - Not Allowed', the Guest User has no access at all - I get the 'Authorization Required' page.

 

I tried deactivating the Site and creating a new one, but my Dev Org only has one Sites license, even if the other is disabled.  And there is no way (that I can see) to delete the Site and start over.

 

So it appears that I am stuck with the Customer Portal: Contact Portal login.  I'm getting an error there as well, and no email is being generated telling me (in my Admin role) what the issue is.

 

Is there a way, through Eclipse perhaps, to delete the Site from Dev Org so that I can try again?

 

 

I am writing a Visualforce page for Opportunities, and while I've updated the setting for the API to 19.0 to get the dependent picklists to work correctly, the Opportunity: Stage(StageName) selections are not being constrained by the Sales Process.

 

I am either creating or editing an Opportunity, and the controller has the Opportunity.RecordTypeId -- is there a way other than manually creating a picklist with the values that I know are valid now?  That seems like an inelegant solution to the problem.

 

I look forward to your suggestions.

I'm looking to do something similar to the Redirect by Record Type solution posted last fall, in which we want to send certain Opportunity Record Type creates/edits to our custom Visualforce page and the rest to the standard pages.

 

Before I get to the point of determining which direction to go, I wrote a very basic Opportunity controller extension to display the RecordTypeId.

 

If I log in as a User with less than Administrator privileges, however, I get an 'insufficient privileges' error and the page doesn't load (and no debug log is generated).

 

My extension is not written 'with sharing', so I should be able to do whatever I need to there, no?  (apparently not).  

 

Here's the code for my extension, and the page (they're both quite short):

 

 

public class SelectOppRecordType_Extension {

private final Opportunity opp;
	
public SelectOppRecordType_Extension(ApexPages.StandardController stdController) {
	opp = (Opportunity)stdController.getRecord();
	String rtName;
		
	if(opp.RecordTypeId <> null){
		RecordType rt = [Select Name from RecordType where Id = :opp.RecordTypeId];
		rtName = rt.Name;
		System.debug('========== RecordType Name = ' + rt.Name);
		
	} else {
		rtName = 'No RecordTypeId to see';
	}
	
	System.debug('====== sName = ' + rtName);
		
    }
		
}

 

 

And the page (The 'why have an inputHidden and an outputText for the same value..?' is not germane, really; trust me) :

 

<apex:page standardController="Opportunity" extensions="SelectOppRecordType_Extension">
	<apex:form >
		<apex:outputPanel >
			<apex:inputHidden id="recordTypeId" value="{!Opportunity.RecordTypeId}" />
			<apex:outputText value="{!Opportunity.RecordTypeId}" />
		</apex:outputPanel>
	</apex:form>
</apex:page>

 

 

I am trying to insert a FeedPost on a Contact when I add a new related record, and I'm using the code from the Chatter Code Recipes to insert a FeedPost:

 

 

FeedPost fpost = new FeedPost();
fpost.ParentId = oId; //eg. Opportunity id, custom object id..
fpost.Body = post;
insert fpost;

 

 

I replaced oId with the associated Contact.Id, but the error is occurring on the previous line: Save error : Invalid type : FeedPost

 

This is my Chatter dev org, so I know it's enabled - is there something else that I need to add when I'm working from a trigger?

I'm trying to revisit my Hackathon app and in the interest of time I installed the TwitterForce classes and am running into the following problem (which has been mentioned on the CodeShare page TwitterForce in February but has not been answered.

 

When I plug in the Remote Site URL http://twitter.com/account/verify_credentials.xml and enter, the URL is truncated to http://twitter.com, and I am thinking this is the cause of the next issue which involves logging in from the included VF page and getting a

 

ParseError at [row,col]:[316,27] Message: expected start or end tag

 

message.

 

I know it's been 1/2 a year since the Hackathon, but does anyone have any insight on this?

 

Thanks!

I created a VF page at the DF09 Hackathon last year to pull in a list of Twitter posts and display it on a VF page, and I'm finally getting around to extending it to capture the list details.  I want to call out to an Apex WebService class that will create new objects based on the feed.

 

The WebService takes the details of my item (the twitter username and message) and returns either 0 or 1, based on whether the record was successfully created or not.

 

Prior to this latest change, the list is generated and displayed inline; after I added the call, the page writes one tweet and stops. 

 

Any help is appreciated!

 

 

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
  <script>
  
  $(document).ready(function(){
  
    $.getJSON("http://search.twitter.com/search.json?callback=?&q={!Twitter_Campaign__C.hashtag__c}",
        function(data){
        
        //console.log(data);
        
          $.each(data.results, function(i,item){
            $("<div>").html("<img src=\"" + item.profile_image_url + "\" />@" + item.from_user + ": " + item.text).appendTo("#results");


    // *** Here's the attempt to call out to my WebService ***
    compareResult = logTweets.createTweet(item.from_user, item.text);

        
          });
          
        });

  });
  </script>

 

 

I have a custom controller and associated VF page that I am trying to deploy, and in the sandbox my Unit Test coverage for the class is showing as 97%.  All of my data is defined in the Unit Test.

 

When I go through the deployment validation in the Force.com IDE, the validation fails because it is only showing 47% test coverage of the same class.

 

All of the unit tests are defined in a single test class, and I am including the test class, the VF pages that it uses, and the controller (as all of the items) in my deployment.

 

There are triggers that also impact the test, but the lowest coverage on any of them is 75%, and the Code Coverage Total in the sandbox summary is 92%.

 

Any thoughts as to what might be causing the discrepancy between the sandbox test results and the IDE deployment wizard's test results? 

I have a after trigger on CampaignMember with a goal to calculate a Lead score based on Campaign participation.  Each Campaign has a set of scores associated to Campaign Member status values, and the trigger rolls these values up to the Lead.

 

Campaign #1- Webinar: Registered - 5pts, Attended - 8pts

Campaign #2- Seminar: Registered - 7pts, Attended - 10pts

 

Joe Lead - attended Webinar (+8), registered for Seminar (+7) for a total of 15 rolled up to the Lead.

 

This appears to be working in the UI, but the Unit Tests are failing because the Campaign Member: Status that I set when I create is changed to 'Sent' when it is inserted in the database.  This happens even if 'Sent' isn't one of the available labels/values for Campaign Member: Status.

 

I checked for Workflow rules that might be setting Status, but there are none.

 

Here's the Unit Test code:

 

 

Lead TestLead1 = new Lead(LastName='TestLead 1', Company='Test Company', Status='Qualified'); insert TestLead1; Campaign TestCampaign1 = new Campaign(Name='Test-Webinar Campaign I', Response_1__c='Responded', Response_1_Score__c=0, Response_2__c='Registered', Response_2_Score__c=4, Response_3__c='Attended', Response_3_Score__c=7); insert TestCampaign1; // Create CampaignMembers, associating the new Leads to their associated Campaigns CampaignMember member1 = new CampaignMember(CampaignId=TestCampaign1.Id, LeadId=TestLead1.Id, Status='Registered'); system.debug('===== InsertSingleCampaignMember:' + TestCampaign1.Name + ', member1(pre-insert)=' + member1.Status + ' ====='); insert member1;

The debug code is confirming that the initial CampaignMember status = 'Registered'

 

Once inside the After trigger, the status appears as 'Sent' (and I changed 'Sent' in the sandbox to 'Solicited'; it still says 'Sent')

 

Again, no workflow.  Here is my Trigger code: 

 

 

Set<Id> setLeadIds = new Set<Id>(); Set<Id> setMemberIds = new Set<Id>(); List<CampaignMember> lstCampaignMembers = new List<CampaignMember>(); List<Lead> lstLeads = new List<Lead>(); // Add the Lead, CampaignMember and Campaign Ids in the trigger to our sets for (CampaignMember member :trigger.new) { if (member.LeadId <> null) { setLeadIds.add(member.LeadId); setCampaignIds.add(member.CampaignId); system.debug('===== processing campaign member ' + member.Status + '...'); ...

At this point ^, when I'm capturing the details of the CampaignMembers in my After trigger, the member Status is 'Sent'.

 

Does this make sense to anybody?!?

 

For overkill' sake, this is what appears when I run my test:

 

 

Class.UnitTests_updateCampaignMembers.test_Insert_SingleLead_SingleCampaign: line 33, column 4: ===== InsertSingleCampaignMember:Test-Webinar Campaign I, member1(pre-insert)=Registered ===== ** so far, so good ** Class.UnitTests_updateCampaignMembers.test_Insert_SingleLead_SingleCampaign: line 35, column 4: Insert: SOBJECT:CampaignMember *** Beginning updateCampaignMembers on CampaignMember trigger event AfterInsert for 00vQ000000077Ry Trigger.updateCampaignMembers: line 24, column 3: SelectLoop:LIST:SOBJECT:CampaignMember 20100109142457.212:Trigger.updateCampaignMembers: line 28, column 5: ===== processing campaign member Sent... ** nope, not so good after all **

 

 

 

 

 

 

I'm working my way through the cookbook and am running into an issue with the 'Building a Table of Data' example. I created a class and a VisualForce page with the example code but the class won't save - the error is 'Save error: Return value must be of type: Account'

public class mySecondController {

public Account getAccount() {
return [select id, name,
(select id, firstname, lastname
from Contacts limit 5)
from Account where id =
:System.currentPageReference()
.getParameters().get('id')];
}

public String getName() {
return 'My Second Custom Controller';
}
}

p.s. is there a wiki section for the Cookbook et.al.? That would be a great way to address issues and provide support - I'm just sayin'

Message Edited by finalist on 11-09-2008 02:47 PM
Hi everyone -

I'm trying to use the example of a VisualForce Email Template on Accounts with related Cases to create an email for one custom object and its related list items.  Referencing the first object is straightforward, but I haven't been able to figure out how to reference the related list.

Code:
<messaging:emailTemplate subject="A foo is required for this case; Do not reply to this email." recipientType="User" relatedToType="foo__c">
<messaging:plainTextEmailBody >

   Case/foo Number: {!relatedTo.Case_Number__c}
   Subject: {!relatedTo.Subject__c}
   ...
   // Here's where the trouble occurs, where foo_item__c is an individual
   // item in a related list
   <apex:repeat var="cx" value="{!relatedTo.foo_Line_Item}">
       {!cx.Detail_Number__c} - {!cx.Replacement_Component__c}
   </apex:repeat>

   // whether I use foo_Line_Item__c, foo_Line_Items, foo_Line_Item__cs - nothing seems to apply


Looking at the schema, the foo__c child object name is foo_Line_Item__c.

Thoughts?
 

Hi everyone,

I'm trying to use the OwnerId from Opportunity to retrieve the associated ManagerId from the User table, and not having any luck. I've found a few references to similar issues but there must be something I'm still missing.

Here is the code:
conn = sforce.connection;

function get_ManagerID() {
// get_ManagerID retrieves the Manager ID from the Opportunity Owner's user record
var newMgrId = new String;
try {
results = conn.query("SELECT ManagerId from User where Id = '" + {!Opportunity.OwnerId} + "'");
var records = results.getArray("records");
if (records.size == 1) {
salesMgrId = records[0].ManagerId;
alert("Sales Mgr = " + salesMgrId );
} else {
alert("Cannot find Manager record for user: " + ownerId);
}
...

I have a catch(ex) that uses an alert to display any error message, but there isn't any -- the process just hangs.
I've written other (successful) queries on other tables but this is the first time I've seen this particular syntax suggested, putting the id in multiple quotes -- normally, I would use "Select ... where Id = '{!Opportunity.OwnerId}' and ... " (just as an example that goes a bit further, to clarify my use of ' and "). The reference to ownerId refers to a global assignment ownerId = '{Opportunity.OwnerId}'; I would've used that in my query, but it wasn't faring any better.

I've also tried trimming it down to "Select ManagerId from User where Id = '"{!Opportunity.OwnerId}"'" and "Select ManagerId from User where Id = '{Opportunity.OwnerId}'", but none seems to work. The Schema Explorer added "Select u.ManagerId From User u ... and worked fine - inside Eclipse, but not the S-Control.

Let me know your thoughts, and thanks!
I've created an S-Control that creates or updates a custom object based on values in an Opportunity, and one of the fields that I'm trying to copy is a long text field.

Everything's fine, as long as there are no newline characters in the field; you know, as long as nobody tried to make their text legible.

As soon as I try to load a record that has a newline in that field, the S-Control locks up; I tried getting around the issue by using sforce.connection.retrieve() rather than directly assigning the value to a variable, but they're both strings in the end, and it doesn't even throw an error, best I can tell; it just dies.

Is there a workaround, or do I just tell the reps to copy the field manually?

... hmm ... where's my toolbar -- I hope this doesn't break anything ...
try {
// conn.retrieve takes ids as an array
oppIds.push(oppId);
result = conn.retrieve("NOTES_FOR_IMC_FROM_SALES__c", "Opportunity", oppIds);

for (i = 0; i < result.length; ++i) {
parseLongText(result[i].NOTES_FOR_IMC_FROM_SALES__c);
}

} catch(ex) {
displayError(ex);
}
I have an S-Control that mimics the functionality of a roll-up summary field for a lookup rather than a Master/Detail relationship.  I'd like the option of being able to call it from a couple of locations, which suggests making it a snippet, or at minimum being able to run it without an interim page load - if it can run and then refresh the page when it's completed, that's all that's required.
 
If it were contained in a snippet, then I could use an 'Execute Javascript' button to pass it the parameter I need, or slip the call into the end of another process as long as I passed in the correct initial Id, correct?
 
Here is the entirety of the S-Control - it's mostly functions, but there are a few variables and includes (or what will be includes, I presume) that would need updating.
I have the cookbook, but I don't see it going into the detail of making this transition.  Any and all help would be appreciated.
 
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<html>
<head>
<script type="text/javascript" src="/js/functions.js"></script>
<script type="text/javascript" language="javascript" src="/soap/ajax/11.1/connection.js"></script>
<script src="/js/dojo/0.4.1/dojo.js"></script>

<script type="text/javascript" language="javascript">

// Salesforce parameter Ids:
// Time Entry: Customer Subscription = 00N70000002JgwU
// Time Entry: Subscription & Service Block = 00N70000002Jgyz

// Assignment of a field: "&CF" + field id + "=" & field
// Example #1: &CF00N70000002Jgxx={!User.Name}
// Example #2: &CF00N70000002Jgyg=0.25

var finishedLocation;
customerSubscriptionName = new String;
serviceBlockId = new String;
hoursRemaining = new Array();
results = new Array();

var conn = sforce.connection;

function displayError(error) {
      // displays a friendlier error message to the user
      alert("An error occurred while processing your request: \n" + error);
};

function getActiveServiceBlocks() {

    try {

              results = conn.query("Select Name, Id, Active__c, Hours_Remaining__c from Subscription_And_Service_Block__c where Customer_Subscription__c = '{!Customer_Subscription__c.Id}' And Active__c = True");

              if (results.size > 0) {
                    var ri = new sforce.QueryResultIterator(results);
                    while (ri.hasNext()) {

                            parseServiceBlock(ri.next());
                    };

                   // - All of the records have been processed and the total hours summed; 
                   //   update the Customer Subscription with the total amount

                   updateTotalHoursRemaining();

            } else {

                  // no records were returned, i.e. there are no active Service blocks
                 alert("There are no active Subscription & Service blocks for this Subscription");

                 noResultsLocation();

           }

      } catch(ex) {
             displayError(ex);
      }
}

function parseServiceBlock(record) {

        // - Capture the start date and Id of the Subscription and Service Block
        subAndServiceBlockName = record.Name;
        serviceBlockId = record.Id;
        var hours = record.Hours_Remaining__c;

        hoursRemaining.push(hours);
}

function updateTotalHoursRemaining() {

       try {
                   var totalHoursRemaining;
                   for(i = 0; i < hoursRemaining.length; ++i) {
                             if (i == 0) {
                                   totalHoursRemaining = hoursRemaining[i];
                             } else {
                                   totalHoursRemaining = parseFloat(totalHoursRemaining) + parseFloat(hoursRemaining[i]);
                             };
                   }

                   updateCustomerSubscription = new sforce.SObject("Customer_Subscription__c");
                   updateCustomerSubscription.Id = '{!Customer_Subscription__c.Id}';
                   // - set Active Hours Remaining using HoursRemaining
                   updateCustomerSubscription.Active_Hours_Remaining__c = totalHoursRemaining;

                   result = conn.update([updateCustomerSubscription]);

                   noResultsLocation();

          } catch(ex) {
                 displayError(ex);
       }

}

function noResultsLocation() {

    try {
        // - Determine whether initial location is in the Console (DesktopPage) or in a tab, to return user to same place
        if(window.parent.location.href=="https://na5.salesforce.com/ui/desktop/DesktopPage")
            {
                finishedLocation = '/{!Customer_Subscription__c.Id}&isdtp=mn';
            } else {
                finishedLocation = '/{!Customer_Subscription__c.Id}';
            };

           window.location = finishedLocation;

     } catch(ex) {
          displayError(ex);
     }
// end function noResultsLocation
}

function init() {
       getActiveServiceBlocks();
}

dojo.addOnLoad(init);

</script>
</head>
<body>
</body>
</html>

 
Thanks!


Message Edited by finalist on 08-21-2008 08:34 PM
I have an S-Control that is triggered from a button, queries the database for related objects,
and winds up on an edit page for a new custom object in either the Console or a tab depending on where we started.
 
If the query is successful, I call a function, determine by window.parent.location.href whether we're in the Console or not and do what I need to do. 
If the query returns no data, I can display a message to the user (very advanced, I know), but I can't figure out how to get back to where I started.
 
I tried using window.parent.location.href = window.parent.location.href, or using a variable for retURL = "{!$Request.retURL}",
but both of these result in an endless loop of message displays and empty pages.
 
The button's behavior is 'Display in existing window without sidebar or header'
 
Here is my code for determining location, which works fine when there's data:
 
Code:
if(window.parent.location.href=="https://na5.salesforce.com/ui/desktop/DesktopPage")
{
    finishedLocation = '/a0H/e—CF00N70000002Jgyz=' + ... 
       + &CF00N70000002JgwU={!Customer_Subscription__c.Name}
       &CF00N70000002JgwU_lkid={!Customer_Subscription__c.Id}
       &retURL=%2F{!Customer_Subscription__c.Id}&isdtp=mn'
}
   else
{
   finishedLocation = '/a0H/e–CF00N70000002Jgyz=' + ... 
       + &CF00N70000002JgwU={!Customer_Subscription__c.Name}
       &CF00N70000002JgwU_lkid={!Customer_Subscription__c.Id}
       &retURL=%2F{!Customer_Subscription__c.Id}&};
}

 
And here's the code that verifies whether I have any actual results:
 
Code:
if (results.size > 0) {
     var ri = new sforce.QueryResultIterator(results);
       while (ri.hasNext()) {
       // parseServiceBlocks calls the previous ^ function
       parseServiceBlock(ri.next());
       };
} else { 
       // no records were returned, i.e. there are no active Service blocks
       alert("There are no active Subscription & Service blocks for this Subscription");

       // At this point, we want to return the user to the original page 

}

 I'm sure there's a simple way to set window.location to something real, but I haven't figured out what it is.
 
Thanks!
 


Message Edited by finalist on 08-20-2008 03:03 PM
I know there's a way to build, and presumably also test, SOQL queries from with the Force.com Eclipse environment, but I am being hampered by the fact that the help browser is only loading contents, i.e. it's indicating that there's information somewhere, but then the pages do not load.  I am connected to the internet, since I'm able to enter this question, but not via Eclipse/Help.

Is there a version of the Force.com/Help online that I can access directly?  Or can someone walk me through running a SOQL query from Europa?

Thanks!

I have a VF component that displays a blank inputfield that, when populated, retrieves the associated custom object record and displays additional data from that record.

 

When viewing the object in a detail page, all records & fields are visible to a particular profile; when I login as that user type, the fields and values are displayed.  When the visualforce page containing the custom component is loaded, the Label appears as an outputLabel, in the same pageBlock /  table as the inputField in question, but the inputfield is not visible at all to this profile. 

 

In the controller I create an empty Code_Map__c object, and then when the user clicks the 'Retrieve Code' button the Serial Number is passed in and the code associated to the Serial Number is displayed in a separate section.

 

While logged in as the user, again, the Serial Number field is displayed w/o an issue.   Any thoughts as to why the apex:inputfield would not show up at all to some profiles?

 

	<apex:pageBlock title="Retrieve Code" id="RetrieveCode">
		<table width="80%">
			<tr>
				<td>
					<apex:outputLabel value="{!$ObjectType.Code_Map__c.Fields.Serial_Number__c.Label}" for="serialNumber" />
				</td>
				<td>
					<apex:inputField id="serialNumber" value="{!cm.Serial_Number__c}" required="true" />
				</td>
			</tr>
			<tr>
				<td>
					<apex:commandButton action="{!fetchCode}" id="fetchCode" value="Retrieve Code" />
				</td>
			</tr>
		</table>
	</apex:pageBlock>

 

I've run into an odd scenario involving a cross-object validation that I'd like some fresh eyes on.  I want to prevent a Case from being created, updated or closed if the Case.Type is not in agreement with the associated Account's recordtype.

 

It sounds like a straightforward use case for a Validation Rule, but insert()s slip on through anyway (perhaps because Account.recordtypeId isn't available until after the Case is first saved..?  Guessing here.)  Updates and Case close are prevented, but that's not enough.

 

So I created a Case trigger (before insert, before update) that checks for Case.Type, creates a Set<Id> of Account Ids for the types I want to validate, retrieves the Account.Ids for the Account recordtypes I care about, and then uses addError() to flag those Cases that violate the rule.

 

i.e. Accounts of recordType 'X' must have Cases of Case.Type "Xtype", or I apply addError('Please use Case type "Xtype" when blah, blah blah');

 

The trigger works great, but is proving difficult to test:

 

#askForce pointed to a great example of Unit Testing for (presumably) an addError() use Testing Example

 

I create a Case with an invalid type, then attempt an insert() or update() using a try/catch block, then use the example to look at the exception - but no exception is thrown.

 

UI works great, though.

if (c.AccountId == a.Id && c.Type <> 'Xtype') {
	c.addError(' You must select a Case type of \'Critical Care\', as this is a Critical Care account.');
}

 

Hi All,

 My company has too many lead assignment rules based on state/province, area and zip code of US. Many rules are defined with combinations of these three codes. I am in the process of eliminating state/province code, and create assignment rules based on area code or zip code. Are there any best practices to manage lead assignment rules? Please let me know, and your suggestions will be very much helpful for me. Thanks much!

 

 

  • January 13, 2011
  • Like
  • 0

I have a single Contact enabled as a Contact Portal user, and created a login and password for that Contact.  Logging in as that user results in an error on my custom page (apparently): "Error: Error occurred while loading a Visualforce page."  No email was generated for the Administrator, though.

 

Is there a way to create a Debug Log for the Contact Portal user?  How can I identify what the VF error is, otherwise?

I am working in my dev org to allow access to a custom visualforce page through Sites.  The page displays a single Account and some related Custom Objects, and i made these accessible to the Guest User profile.  I was seeing the page but without details (though the Custom Controller is hard-coded to display a particular Account), so I decided to see what I could gain access to through using the Customer Portal.  The Customer Portal has access to even fewer objects than the Guest User (no custom objects at all), so that was a wrong move, but now although I deselected Login Enabled so that on the Sites detail page is reads 'Login - Not Allowed', the Guest User has no access at all - I get the 'Authorization Required' page.

 

I tried deactivating the Site and creating a new one, but my Dev Org only has one Sites license, even if the other is disabled.  And there is no way (that I can see) to delete the Site and start over.

 

So it appears that I am stuck with the Customer Portal: Contact Portal login.  I'm getting an error there as well, and no email is being generated telling me (in my Admin role) what the issue is.

 

Is there a way, through Eclipse perhaps, to delete the Site from Dev Org so that I can try again?

 

 

I'm looking to do something similar to the Redirect by Record Type solution posted last fall, in which we want to send certain Opportunity Record Type creates/edits to our custom Visualforce page and the rest to the standard pages.

 

Before I get to the point of determining which direction to go, I wrote a very basic Opportunity controller extension to display the RecordTypeId.

 

If I log in as a User with less than Administrator privileges, however, I get an 'insufficient privileges' error and the page doesn't load (and no debug log is generated).

 

My extension is not written 'with sharing', so I should be able to do whatever I need to there, no?  (apparently not).  

 

Here's the code for my extension, and the page (they're both quite short):

 

 

public class SelectOppRecordType_Extension {

private final Opportunity opp;
	
public SelectOppRecordType_Extension(ApexPages.StandardController stdController) {
	opp = (Opportunity)stdController.getRecord();
	String rtName;
		
	if(opp.RecordTypeId <> null){
		RecordType rt = [Select Name from RecordType where Id = :opp.RecordTypeId];
		rtName = rt.Name;
		System.debug('========== RecordType Name = ' + rt.Name);
		
	} else {
		rtName = 'No RecordTypeId to see';
	}
	
	System.debug('====== sName = ' + rtName);
		
    }
		
}

 

 

And the page (The 'why have an inputHidden and an outputText for the same value..?' is not germane, really; trust me) :

 

<apex:page standardController="Opportunity" extensions="SelectOppRecordType_Extension">
	<apex:form >
		<apex:outputPanel >
			<apex:inputHidden id="recordTypeId" value="{!Opportunity.RecordTypeId}" />
			<apex:outputText value="{!Opportunity.RecordTypeId}" />
		</apex:outputPanel>
	</apex:form>
</apex:page>

 

 

Hi Friends

 

I have using 4 custom objects such as contact , lead, Listing, closing . I have been removed  the new button on those custom object search layout page(Buttons displayed) . but these objects list view page has displayed new standard button. How to remove the standard new button from the custom objects list view page.?please post ur suggestion

 

 

Thanks

Sundar

I am trying to insert a FeedPost on a Contact when I add a new related record, and I'm using the code from the Chatter Code Recipes to insert a FeedPost:

 

 

FeedPost fpost = new FeedPost();
fpost.ParentId = oId; //eg. Opportunity id, custom object id..
fpost.Body = post;
insert fpost;

 

 

I replaced oId with the associated Contact.Id, but the error is occurring on the previous line: Save error : Invalid type : FeedPost

 

This is my Chatter dev org, so I know it's enabled - is there something else that I need to add when I'm working from a trigger?

I created a VF page at the DF09 Hackathon last year to pull in a list of Twitter posts and display it on a VF page, and I'm finally getting around to extending it to capture the list details.  I want to call out to an Apex WebService class that will create new objects based on the feed.

 

The WebService takes the details of my item (the twitter username and message) and returns either 0 or 1, based on whether the record was successfully created or not.

 

Prior to this latest change, the list is generated and displayed inline; after I added the call, the page writes one tweet and stops. 

 

Any help is appreciated!

 

 

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
  <script>
  
  $(document).ready(function(){
  
    $.getJSON("http://search.twitter.com/search.json?callback=?&q={!Twitter_Campaign__C.hashtag__c}",
        function(data){
        
        //console.log(data);
        
          $.each(data.results, function(i,item){
            $("<div>").html("<img src=\"" + item.profile_image_url + "\" />@" + item.from_user + ": " + item.text).appendTo("#results");


    // *** Here's the attempt to call out to my WebService ***
    compareResult = logTweets.createTweet(item.from_user, item.text);

        
          });
          
        });

  });
  </script>

 

 

Along with a co-worker, we are trying to write a trigger to update the chatter on our Opportunities with the ProductCode from the line item. We are not having much success. We do have a working trigger

 

 

trigger LineItemToOpportunityFeedUpdate on OpportunityLineItem (after update) {
    List<FeedPost> posts = new List<FeedPost>();
    
    for(OpportunityLineItem newOLI : Trigger.new) {
        OpportunityLineItem oldOLI = Trigger.oldMap.get (newOLI.id);
        System.debug('New: '+newOLI.Part_Outcome__c+' Old: '+oldOLI.Part_Outcome__c);
        
        if(newOLI.Part_Outcome__c != oldOLI.Part_Outcome__c) {
            
            List<OpportunityFeed> opportunityFeedPosts = [SELECT Id, Type, FeedPost.Body
                                                            From OpportunityFeed
                                                            Where ParentID = :newOLI.OpportunityID
                                                            ORDER BY CreatedDate DESC];
            
                                                                     
            String bodyText = 'Socket outcome was changed from '+oldOLI.Part_Outcome__c+' to '+newOLI.Part_Outcome__c+'.';     
            
            //I would put in the '+lineitem.UnitPrice+' command before the .'; in line 19.
            
            if(opportunityFeedPosts.size() == 0 || opportunityFeedPosts[0].FeedPost.Body != bodyText) {
                //System.debug('OpportunityFeed Posts: '+opportunityFeedPosts[0]);
                
                FeedPost opportunityPost = new FeedPost ();
                opportunityPost.Type = 'LinkPost';
                opportunityPost.Title = 'Socket XYZ has been set to '+newOLI.Part_Outcome__c+'';
                opportunityPost.Body = bodyText;
                String id = String.valueOf(newOLI.id).substring(0,15);
                opportunityPost.LinkURL = 'https://cs2.salesforce.com/'+id;
                opportunityPost.ParentID = newOLI.opportunityid;
                posts.add(opportunityPost);
               }
            }
        }
        insert posts;
}

 

 

If you notice, we have a custom field called the part_outcome__c , which is updating, but we are trying to get the Product code and when we attempt to get the Product Code or part number on the chatter area;

 

Currently chatter using the part_outcome__c looks like this:

 

 

Can someone please help me correct this trigger so we can get the productcode on the chatter. Just for Clarification, our socket = ProductCode

 

 

We are attempting to use a trigger to create a FeedPost of type LinkPost that will update the User's status and provide a link to a salesforce record.  This trigger will be packaged and distributed to orgs across many salesforce.com instances (nax, emea, apac, sandbox, etc), so we need to make the server url in the link dynamic based on the org's location.

 

Since we are only using a trigger in this package, there are no VF pages to capture the url and store it.  We could go that route, but are trying to avoid it.

 

Our best solution so far has been to build our url based on a formula field on the object from which the trigger is fired:

 

SUBSTITUTE(LEFT($Api.Enterprise_Server_URL_180, FIND("salesforce.com", $Api.Enterprise_Server_URL_180)-1), "-api", "")

 

This works well for NA instances, but for emea, the Enterprise Server URL is "eu", so the links created with this formula are invalid for emea users.

 

I'm looking for some best practices from the community as to how you all would address this problem.  Thanks in advance for any feedback.

 

 

I have a custom controller and associated VF page that I am trying to deploy, and in the sandbox my Unit Test coverage for the class is showing as 97%.  All of my data is defined in the Unit Test.

 

When I go through the deployment validation in the Force.com IDE, the validation fails because it is only showing 47% test coverage of the same class.

 

All of the unit tests are defined in a single test class, and I am including the test class, the VF pages that it uses, and the controller (as all of the items) in my deployment.

 

There are triggers that also impact the test, but the lowest coverage on any of them is 75%, and the Code Coverage Total in the sandbox summary is 92%.

 

Any thoughts as to what might be causing the discrepancy between the sandbox test results and the IDE deployment wizard's test results? 

I have a after trigger on CampaignMember with a goal to calculate a Lead score based on Campaign participation.  Each Campaign has a set of scores associated to Campaign Member status values, and the trigger rolls these values up to the Lead.

 

Campaign #1- Webinar: Registered - 5pts, Attended - 8pts

Campaign #2- Seminar: Registered - 7pts, Attended - 10pts

 

Joe Lead - attended Webinar (+8), registered for Seminar (+7) for a total of 15 rolled up to the Lead.

 

This appears to be working in the UI, but the Unit Tests are failing because the Campaign Member: Status that I set when I create is changed to 'Sent' when it is inserted in the database.  This happens even if 'Sent' isn't one of the available labels/values for Campaign Member: Status.

 

I checked for Workflow rules that might be setting Status, but there are none.

 

Here's the Unit Test code:

 

 

Lead TestLead1 = new Lead(LastName='TestLead 1', Company='Test Company', Status='Qualified'); insert TestLead1; Campaign TestCampaign1 = new Campaign(Name='Test-Webinar Campaign I', Response_1__c='Responded', Response_1_Score__c=0, Response_2__c='Registered', Response_2_Score__c=4, Response_3__c='Attended', Response_3_Score__c=7); insert TestCampaign1; // Create CampaignMembers, associating the new Leads to their associated Campaigns CampaignMember member1 = new CampaignMember(CampaignId=TestCampaign1.Id, LeadId=TestLead1.Id, Status='Registered'); system.debug('===== InsertSingleCampaignMember:' + TestCampaign1.Name + ', member1(pre-insert)=' + member1.Status + ' ====='); insert member1;

The debug code is confirming that the initial CampaignMember status = 'Registered'

 

Once inside the After trigger, the status appears as 'Sent' (and I changed 'Sent' in the sandbox to 'Solicited'; it still says 'Sent')

 

Again, no workflow.  Here is my Trigger code: 

 

 

Set<Id> setLeadIds = new Set<Id>(); Set<Id> setMemberIds = new Set<Id>(); List<CampaignMember> lstCampaignMembers = new List<CampaignMember>(); List<Lead> lstLeads = new List<Lead>(); // Add the Lead, CampaignMember and Campaign Ids in the trigger to our sets for (CampaignMember member :trigger.new) { if (member.LeadId <> null) { setLeadIds.add(member.LeadId); setCampaignIds.add(member.CampaignId); system.debug('===== processing campaign member ' + member.Status + '...'); ...

At this point ^, when I'm capturing the details of the CampaignMembers in my After trigger, the member Status is 'Sent'.

 

Does this make sense to anybody?!?

 

For overkill' sake, this is what appears when I run my test:

 

 

Class.UnitTests_updateCampaignMembers.test_Insert_SingleLead_SingleCampaign: line 33, column 4: ===== InsertSingleCampaignMember:Test-Webinar Campaign I, member1(pre-insert)=Registered ===== ** so far, so good ** Class.UnitTests_updateCampaignMembers.test_Insert_SingleLead_SingleCampaign: line 35, column 4: Insert: SOBJECT:CampaignMember *** Beginning updateCampaignMembers on CampaignMember trigger event AfterInsert for 00vQ000000077Ry Trigger.updateCampaignMembers: line 24, column 3: SelectLoop:LIST:SOBJECT:CampaignMember 20100109142457.212:Trigger.updateCampaignMembers: line 28, column 5: ===== processing campaign member Sent... ** nope, not so good after all **

 

 

 

 

 

 

I'm creating a visualforce page that will direct a user from a site to a contact, but have multiple contact record types.  Is there a way I can determine which record type is correct for the user in the visual force?  Or is there a way to ask them before the record is created?  Right now I have:

 

       public void pageredir(){
 
       String URL='/003/e';
        URL=URL+'?retURL=/'+s.id;
        URL=URL+'&nooverride=1';
        URL=URL+'&RecordType=012700000005IBE';
        URL=URL+'&what_id='+s.id;
        URL=URL+'&con4_lkid='+smAcctid ;

 

Thank you.