• trmp
  • NEWBIE
  • 30 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 37
    Replies
We have a community where community users can open cases. We are inserting the case via Apex which changes the owner due to using the default case assignment rule:

Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule= true;
dmo.EmailHeader.triggerAutoResponseEmail = false;
caseRecord.setOptions(dmo);

insert caseRecord;
Without adding a CaseShare record, the community user will no longer be able to access the newly created case. However, when inserting the CaseShare record, we cannot get around this error:

Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []

Here's a snippet of adding the CaseShare record. We've tried this in the above class marked as "without sharing", in a future method from a trigger, with and without also adding an AccountShare record.

insert new CaseShare(
    CaseAccessLevel = 'Read',
    CaseId = c.Id,
    UserOrGroupId = c.CreatedById
);
Any help would be much appreciated.
  • September 11, 2014
  • Like
  • 0
We believe this is a bug with Field-Level Security within managed package updates.

Steps to reproduce:
Install a managed package that has a managed object without a managed Type__c field (namespaced).
Create your own Type__c field (not namespaced) on that managed object.
Install a new version of the same managed package that contains a Type__c field (namespaced) on the same managed object - make sure to select "Grant access to all users" on the security step. This is supposed to give full access to all new components, including new fields.
See that FLS is not set for the managed Type__c field.
  • May 16, 2014
  • Like
  • 2

Merging two contacts:

 

Contact c1 = new Contact(firstname='bob', lastname='smith');
Contact c2 = new Contact(firstname='bob', lastname='smith', description='Test Description');
insert new List<Contact>{ c1, c2 };

merge c1 c2;
System.assertEquals('Test Description', c1.description);

 This code gives the following failure:

System.AssertException: Assertion Failed: Expected: Test Description, Actual: null

 

Is it expected behavior for the Apex merge statement to not merge the data from the deleted contacts into the master contact? 

 

Thanks!

  • September 06, 2013
  • Like
  • 0

It is easy to construct the URL for a new button for one of the standard objects:

 

/00b/e?type=Opportunity&setupid=OpportunityLinks&PageOrSobjectType=Opportunity&retURL=%2Fp%2Fsetup%2Flink%2FCustomResourceLinkList%3FpageName%3DOpportunity%26type%3DOpportunity%26setupid%3DOpportunityLinks%26retURL%3D%252Fui%252Fsetup%252FSetup%253Fsetupid%253DOpportunity

For custom objects, the URL uses an Id (prefix 01I) in place of "Opportunity" in the above example. I haven't been able to determine if there is any way to get the corresponding Id for a custom object in order to generate this link. Replacing the Id with the object name or API name doesn't work. I've also tried using URLFOR with the Weblink object, which doesn't work. Has anyone done this or have any ideas?

 

Thanks!!

  • March 19, 2013
  • Like
  • 0

Problem:

 

I have two objects, A and B. They are currently related by a lookup field (B has lookup to A) because I have already maxed out the master-detail depth on the children of object B. I need some of the child B records to inherit the sharing rules from the parent A record. (When a sharing rule gets added or removed from A, it adds/removes the same sharing on some of the B records.)

 

Attempt at a solution:

 

Well, I cannot create Apex triggers on any Sharing objects, so I am trying to use Apex Sharing Recalculations. The problem here is that I cannot tell from the documentation when sharing rules are calculated or recalculated automatically (when the Apex class would be executed) and all my tests have prooven fruitless.

 

As a last resort, I can probably provide a custom "Update Sharing" button, but I would really prefer not to have to do that.

 

Thanks.

  • August 20, 2012
  • Like
  • 0

This is more of an FYI in case anyone comes across this. I have logged a case with Salesforce Support on this issue.

 

If you create a formula field in Salesforce that includes

BR() & Email

 for any email field, Salesforce will produce invalid HTML. Specifically, a br tag will be inserted into the mailto link tag.

 

Work around: Include some whitespace or text between the BR and the Email field, like so

BR() & " " & Email

 Hope this helps someone!

  • May 01, 2012
  • Like
  • 0

1. Does anyone know how this idea is marked as "Delivered"? There is no explanation as to how to use this.

http://success.salesforce.com/ideaView?id=08730000000XbidAAC

 

2. How did this idea get merged into the one above? They don't appear to be the same idea and there is no explanation as to why they were merged.

http://success.salesforce.com/ideaView?id=08730000000ZK3SAAW

 

Thanks.

  • March 30, 2012
  • Like
  • 0

Does anyone know if it is possible using the Force.com Migration Tool (Ant) to migrate page layouts and field changes (new picklist values, record type assignments, etc.) without running the Apex test methods in the target org? I do not see why page layout changes should cause test methods to run, and if a class or trigger is not based on a field being updated, it would also be great if the test methods could be avoided. This may be better placed on the idea exchange, but I thought I'd try my luck here first.

 

Thanks!

  • March 21, 2012
  • Like
  • 0

I have a custom save method that sets a Savepoint, does some inserts and either rolls back (using Database.rollback) if there's an error or redirects to one of the newly inserted records. I just started testing the roll back functionality and it is not working as I would expect. The insert is in fact rolled back, but instead of being sent back to the Visualforce page I was just on, I am sent to a Salesforce error page saying "Data Not Available". It seems to me like the roll back might be removing the view state of the Visualforce page or something strange.

 

public PageReference save() {
	Savepoint beforeInserts = Database.setSavepoint();
	if (trySave() == true) {
		return (new ApexPages.StandardController(record)).view();
	}
	Database.rollback(beforeInserts);
	return null;
}

private boolean trySave() {
    //do some validation and such
    try {
        insert record;
    }
    catch (Exception err) {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, err.getMessage()));
        return false;
    }
    return false; //to test the roll back
}

 Has anyone seen something like this?

 

Thanks!

  • November 19, 2011
  • Like
  • 0
We believe this is a bug with Field-Level Security within managed package updates.

Steps to reproduce:
Install a managed package that has a managed object without a managed Type__c field (namespaced).
Create your own Type__c field (not namespaced) on that managed object.
Install a new version of the same managed package that contains a Type__c field (namespaced) on the same managed object - make sure to select "Grant access to all users" on the security step. This is supposed to give full access to all new components, including new fields.
See that FLS is not set for the managed Type__c field.
  • May 16, 2014
  • Like
  • 2
We have a community where community users can open cases. We are inserting the case via Apex which changes the owner due to using the default case assignment rule:

Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule= true;
dmo.EmailHeader.triggerAutoResponseEmail = false;
caseRecord.setOptions(dmo);

insert caseRecord;
Without adding a CaseShare record, the community user will no longer be able to access the newly created case. However, when inserting the CaseShare record, we cannot get around this error:

Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []

Here's a snippet of adding the CaseShare record. We've tried this in the above class marked as "without sharing", in a future method from a trigger, with and without also adding an AccountShare record.

insert new CaseShare(
    CaseAccessLevel = 'Read',
    CaseId = c.Id,
    UserOrGroupId = c.CreatedById
);
Any help would be much appreciated.
  • September 11, 2014
  • Like
  • 0
We believe this is a bug with Field-Level Security within managed package updates.

Steps to reproduce:
Install a managed package that has a managed object without a managed Type__c field (namespaced).
Create your own Type__c field (not namespaced) on that managed object.
Install a new version of the same managed package that contains a Type__c field (namespaced) on the same managed object - make sure to select "Grant access to all users" on the security step. This is supposed to give full access to all new components, including new fields.
See that FLS is not set for the managed Type__c field.
  • May 16, 2014
  • Like
  • 2

Merging two contacts:

 

Contact c1 = new Contact(firstname='bob', lastname='smith');
Contact c2 = new Contact(firstname='bob', lastname='smith', description='Test Description');
insert new List<Contact>{ c1, c2 };

merge c1 c2;
System.assertEquals('Test Description', c1.description);

 This code gives the following failure:

System.AssertException: Assertion Failed: Expected: Test Description, Actual: null

 

Is it expected behavior for the Apex merge statement to not merge the data from the deleted contacts into the master contact? 

 

Thanks!

  • September 06, 2013
  • Like
  • 0

I've created a new list view for Contacts and made it available to all Users. When I run .getListViewOptions() it only returns 'All'. I'm also logged in as the admin user. Any idea why no others are showing up?

 

public class Ctl_CreateContactsForms {

    public ApexPages.StandardSetController setCtrl{get; set;}
    public string filterOption {get;set;}
    
    public Ctl_CreateContactsForms () {
    	setCtrl = new ApexPages.StandardSetController(Database.getqueryLocator([Select Id,Name FROM Contact]));
 		setCtrl.setPageSize(5); 		
    }  
	
	public list<SelectOption> getallListViewOptions () {
		system.debug('setCtrl.getListViewOptions()'+setCtrl.getListViewOptions());
		return setCtrl.getListViewOptions();
	}
	
    // Initialize setCon and return a list of records
    public List<Contact> getcontactList() {
        return (list<Contact>) setCtrl.getRecords();
    }
}

 

It is easy to construct the URL for a new button for one of the standard objects:

 

/00b/e?type=Opportunity&setupid=OpportunityLinks&PageOrSobjectType=Opportunity&retURL=%2Fp%2Fsetup%2Flink%2FCustomResourceLinkList%3FpageName%3DOpportunity%26type%3DOpportunity%26setupid%3DOpportunityLinks%26retURL%3D%252Fui%252Fsetup%252FSetup%253Fsetupid%253DOpportunity

For custom objects, the URL uses an Id (prefix 01I) in place of "Opportunity" in the above example. I haven't been able to determine if there is any way to get the corresponding Id for a custom object in order to generate this link. Replacing the Id with the object name or API name doesn't work. I've also tried using URLFOR with the Weblink object, which doesn't work. Has anyone done this or have any ideas?

 

Thanks!!

  • March 19, 2013
  • Like
  • 0

Hi All,

 

I needed to send an email notification on opportunities with conditions too complex for a workflow rule, so I created a trigger that checks the conditions and sends the email. I was successful on doing this, but now only problem I have is that the notification needs to be sent from a general address (org wide address), and this address should be available only for the trigger, not for the users. But if I do not add the profiles of the users to the org wide address, I get the following error:

 

caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_OR_READONLY, Not profiled to access this Org-wide Email

 

On the other hand, if I give access to the profiles, then the org wide address is available whenever the users want to send any email message.

 

Does anyone know how to use the org wide address in a trigger without providing access to the user’s profile? Any other solution like running the code always under another user (i.e. system admin)?

 

Thanks in advance!

Hello Everyone,

 

The title is pretty explanatory,

I am using the HYPERLINK() function on a field with no spaces or breaks and it's still rendering with extra text and no hyperlink.

 

This issue is mentioned here:

http://success.salesforce.com/ideaview?id=08730000000BqBQAA0

But in that case it had to do with the hyperlink containing spaces which mine does not.

Anyone found a way to get this to work?

 

I'm hoping someone can tell me what I'm doing wrong here.  Whenever I press the "Count Selected" button, this is what shows up in the debug log no matter how many records I have manually selected on the displayed page:

 

[20]|DEBUG|xyzzy: Num Selected 0

 

Here is the page, followed by the controller.  Obviously these are slimmed down from the actual page and controller I am working on.

 

<apex:page standardController="Account" recordSetVar="true" extensions="aaaDonNotPackageController" id="page">
    <apex:pageBlock mode="mainDetail" id="PB" >
        <apex:form id="form">
            <apex:commandButton value="Count Selected" action="{!CountSelected}" /> 
        </apex:form>            
        <apex:enhancedList id="list" type="Account" height="570" width="1200" rowsPerPage="25"  customizable="true"/>
    </apex:pageBlock>
</apex:page>

 

global with sharing class aaaDonNotPackageController 
{
    public ApexPages.StandardSetController setController;
 
    // Constructor    
    public aaaDonNotPackageController (ApexPages.StandardSetController controller)
    {
        Initialize(controller);
    }   
    
    // placed outside constructor for easier debugging    
    private void Initialize (ApexPages.StandardSetController controller)
    {
        setController = controller;
    }
    
    public void CountSelected()
    {
        List<sObject> selAccts = setController.getSelected (); 
        system.debug ('xyzzy: Num Selected ' + string.valueof(selAccts.size()));                    
    }
}

 

1) I am trying again to get selected rows (with getSelected() on the controller) from an Enhanced list view in a VF page. Am I doing something wrong or is it just not possible to pass the EnhancedList records to a custom controller? It seems that the Enhanced list recordset should be bound to the controller records but I cannot figure out where this should happen.

 

2) BTW, I also try to change the FilterID in the EnhancedList but it does not refresh properly. Is this a known issue?

 

Here is the code. Any help would be great.

<apex:page standardController="Contact" extensions="pgContactHomeController" showHeader="true" tabStyle="Contact" recordSetVar="myContacts">

	<apex:form >
        <apex:selectList value="{!FilterID}" size="1">
            <apex:actionSupport event="onchange" rerender="listPanel"/>
            <apex:selectOptions value="{!listviewoptions}"/>
        </apex:selectList>
    </apex:form>
    
	<apex:outputPanel layout="block" id="listPanel">
		<apex:enhancedList height="300" ListId="{!FilterID}" rowsPerPage="10" id="ContactList" customizable="True"  reRender="debugPanel"/>
	</apex:outputPanel>    

	<apex:outputPanel layout="block" id="debugPanel">
    	<apex:pageblock id="myBlock">
	  		<apex:outputText value="Records={!recordCount}" /> <br/>
			<apex:outputText value="Selected={!selectedCount}" /> <br/>
			<apex:outputText value="FilterID={!FilterID}" /> <br/>
		</apex:pageblock>
	</apex:outputPanel>
	
</apex:page>
public with sharing class pgContactHomeController {
    private ApexPages.StandardSetController myController;
    public pgContactHomeController(ApexPages.StandardSetController stdController) {
     this.myController = stdController;
    }
public Integer getRecordCount(){
return ((List<Contact>)myController.getRecords()).size();
}
public Integer getSelectedCount(){
return ((List<Contact>)myController.getSelected()).size();
}
public Id getFilterID(){
return (myController.getFilterID());
}
public void setFilterID(ID newID){
myController.setFilterID(newID);
return;
}
}

 

 

 

  • March 04, 2011
  • Like
  • 0

I have exactly the same issue as in MD Chen post on ideas. How do you get selected records from a enhancedList? Here is the code:

 

Page

 

<apex:page standardController="ProfileHierarchy__c" recordSetvar="profiles" extensions="testController">
  <apex:enhancedlist type="ProfileHierarchy__c" height="200" rerender="c1,c2" />
  <apex:outputText id="c1" value="c1={!c1}" /> <br>
  <apex:outputText id="c2" value="c2={!c2}" /> <br>
</apex:page>

 Controller

 

public class testController {

  public testController (ApexPages.StandardSetController controller){
    li=controller;
  }

  public ApexPages.StandardSetController li{get;set;}

  public Integer getC1(){
    return ((List<ProfileHierarchy__c>)li.getRecords()).size();
  }

  public Integer getC2(){
    return ((List<ProfileHierarchy__c>)li.getSelected()).size();
  }
}

Thank you.

 

 

 

  • March 01, 2011
  • Like
  • 0

Hello,

I'm having a deal with enhancedList component.
I cannot figure out how to get selected items from there.  
I've tried to do it like for selectList but it doesn't work.

Please advise how to access selected items in enhancedList from controller.
Any suggestions would be appreciated.

Thanks.

Hi, I need to deal with the selected records from enhancedlist view. In my custom controller, I always get "c2=0" by using controller.getSelected() whenever I make the selection in the listview and then click the "get seleted" link.   What is the event for the selection?

 

And getRecords() can not return more than 20 that is not useful for the project.

 

And getRecords() can not get refresh when I select another view in the view option dropdown list.



I really appraciate if anybody has a idea! 

 

My test page:

<apex:page standardController="ProfileHierarchy__c" recordSetvar="profiles" extensions="testController">

<apex:enhancedlist type="ProfileHierarchy__c" height="200" rerender="c1,c2" />

<apex:outputText id="c1" value="c1={!c1}" /> <br>
<apex:outputText id="c2" value="c2={!c2}" /> <br>
<apex:form >
<apex:commandLink action="{!setC2}" value="get selected" reRender="c2" />
</apex:form>
</apex:page>

my controller:

 public class testController {

public testController (ApexPages.StandardSetController controller)
{
 li=controller;
}

public ApexPages.StandardSetController li{get;set;}

 

public Integer getC1(){
return ((List<ProfileHierarchy__c>)li.getRecords()).size();
}


public Integer c2=0;
public Integer getC2(){
 return c2;
}
public void setC2(){
 c2 = ((List<ProfileHierarchy__c>)li.getSelected()).size()+1;
}

}

Does anyone know why an email alert triggered from a workflow would not be creating the associated activity history? Emails sent through the interface, through Apex, and through the API are all logged in activity history (when the appropriate information is set). The email alert is set to be sent to the Contact Email (standard) field.

Thanks!

There's either a bug with the platform, or with the developer (me).  The following code yields a system crash:

 

	public ApexPages.StandardSetController leadSet {		get {			if(leadSet == null) {				leadSet = new ApexPages.StandardSetController(Database.getQueryLocator([select  id, name from Account where id=null]));				List<SelectOption> lvl=leadSet.getListViewOptions();				system.debug('size: '+lvl.size()); // Fail is here			}			return leadSet;		}		set;	}

 

What I'm trying to do is fetch a list of possible filter IDs, and set the filter ID to something, just so there's some initial valid value.  However, anytime I try to do any list-type things to my SelectOption list returned from getListViewOptions, I get a crash.  I can't call size() or for-loop iterate.  I can't even do lvl[0].  Just shuts the whole thing down with the "Internal Server Error."

 

Am I doing something completely wrong here? 

We send our customer portal users a VF email template that contains links to documents and detail pages in the Customer Portal.  If a user is not already logged into the portal (which, 95% of the time, they are not), when they click the link they will be directed to www.salesforce.com to logging.  This will confuse our users....as they need to logging from our website.

 

So how can I change the default behavior of the outputlink to redirect the portal user to our homepage rather than www.salesforce.com?

 

Thanks!

 

 

 

 

We recently ran into a problem when we create a document via the api when the document name is the same. The error we are getting is

"Create Failed: DUPLICATE_DEVELOPER_NAME: This Document Unique Name already exists.  Please choose a unique name. -- DeveloperName"

I thought that specifying the DeveloperName on the document object would be enough, but when I try that, the error I get is

"Create Failed: INVALID_FIELD_FOR_INSERT_UPDATE: Document: bad field names on insert/update call: DeveloperName -- DeveloperName"

This seems a bit contradictory. Any help would be greatly appreciated. Thanks!