• CarlB
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 62
    Questions
  • 52
    Replies
Hello.

I was wondering if anyone else had come across this problem with the latest release.  I have a custom object which has a lookup field to Contact and some record types.  I have created a VF page that overrides the standard "New" action for this object.  In classic Salesforce, if I go to a Contact and create a new instance of my custom object from the related list, the lookup field in that object is automatically populated with the Contact.  However, if I switch to Lightning, there are two issues.  Firstly, the standard record type selection screen is incorrectly formatted (I suspect a missing CSS file).  Secondly (and more importantly), the lookup field is no longer populated.

It seems that during the update, Salesforce have changed something which means that Lightning is no longer backwardly compatible with VF.

Has anyone else encountered this and is there a work-around?

Regards,

Carl
 
  • June 20, 2017
  • Like
  • 0
Hello.

I have a managed package that I install into customers' orgs.  The customers then create a Site which needs to access some of the custom objects in my managed package.  They set up the Guest User to have permission to read and modify the necessar custom objects.  However, at this point, although the objects are readable, some of the fields within those objects are not.  Salesforce seems to randomly decide which fields are accessible by default.

Is there some way to tell Salesforce which fields should be readable or can someone explain how Salesforce determines which fields are readable by default for a Site Guest user?

Regards,

Carl
 
  • June 13, 2017
  • Like
  • 0
If I am running some Apex code that generates an uncaught exception, everything is rolled back automatically - changes to records, send emails, future tasks, etc.

Is there anything that does not get rolled back?

The reason I am asking is because I wish to provide an audit log of operations (even unsuccessful ones).  Obviously there is the debug log, but that only appears if enabled, doesn't handle managed packages very well, and no longer appears for Sites guest users unless you jump through hoops (which isn't always possible).

Any suggestions gratefully received.

Regards,

Carl
  • February 08, 2017
  • Like
  • 0
Hello.

I know that it is possible to import a client certificate (stored in a Java keystore) using the user interface.  What I was wondering if it was possible to do it using Apex?  Is there a Salesforce object that I can manipulate or API call that I can make?

Regards,

Carl
  • December 19, 2016
  • Like
  • 0
We have an application which receives HTTP POSTs from a 3rd party via a Saleforce Site.

Unfortunately a recent "improvement" from Salesforce in the Winter 17 release (https://help.salesforce.com/apex/HTViewSolution?id=000247187&language=en_US) means that we can no longer get debug logs for this, because the POST now needs to contain a cookie to enable debug logs.

Obviously, because the POST comes from a 3rd party, we cannot get this cookie set, hence we cannot get debug logs for these posts.

We raised a case with Salesforce about this and were told that we should raise it on the Idea Exchange.

Has anyone got a work-around for this as it makes dealing with configuration issue between the 3rd party and us impossible to resolve.

Thanks,

Carl



 
  • October 14, 2016
  • Like
  • 0
Hello.

I have a managed package that is build on another managed package.  In particular I have interfaces in one managed package that extend (global) interfaces in the other managed package (e.g.
 
MANAGED PACKAGE A:

global interface A {

    void A();
}


MANAGED PACKAGE B:

global interface B extends A.A {

}
)

Normally this doesn't cause a problem, but recently I tried to install my managed package in an org and the install failed saying the method A() didn't exist in interface B, which clearly it does.

I got around this by changing my code to explicitly reference interface A rather than interface B, e.g.
 
ORIGINAL CODE:

B b = ....

b.A();




NEW CODE:

B b = ...

A a = (A)b;
a.A();


This got around the problem, but once I had uploaded a new version of managed package B, some of the unit tests started failing with the error:
 
Dynamic query yields incompatible SObject type B.B for loop variable of type A.A
These unit tests worked before, but it seems that Salesforce has go in a mess.

Can anyone offer a workaround?

Regards,

Carl




 
  • August 12, 2016
  • Like
  • 0
Hello.

I have a customer's org into which I have installed a managed package.  On the org is some Apex code that calls a method in the managed package.  One of the things that the method does is make a SOQL select statement, but this fails saying "No such column".  However, if I run exactly the same SOQL statement outside of the managed package, it works.

Here is a sample of the code:
 
System.debug('HERE2: ' + [SELECT BillingAddress,ShippingStreet,ShippingCity,ShippingState,ShippingPostalCode,ShippingCountry,ShippingAddress,Phone,Fax,Website,Sic,Industry,AnnualRevenue,NumberOfEmployees,Ownership,TickerSymbol,Description,Rating,Site,OwnerId,CreatedDate,CreatedById,LastModifiedDate,LastModifiedById,SystemModstamp,LastActivityDate,LastViewedDate,IsPartner,IsCustomerPortal FROM Account Where Id in :setaccountId]);
Account member = (Account)(XXXXXXX.Util.getSObjects(setAccountId)[0]);

This is the debug log:
 
16:25:15.8 (1244514753)|SOQL_EXECUTE_BEGIN|[49]|Aggregations:0|SELECT Id, IsDeleted, MasterRecordId, Name, Type, RecordTypeId, ParentId, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry, BillingAddress, ShippingStreet, ShippingCity, ShippingState, ShippingPostalCode, ShippingCountry, ShippingAddress, Phone, Fax, Website, Sic, Industry, AnnualRevenue, NumberOfEmployees, Ownership, TickerSymbol, Description, Rating, Site, OwnerId, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, LastActivityDate, LastViewedDate, IsPartner, IsCustomerPortal FROM Account WHERE Id = :tmpVar1
16:25:15.8 (1278032882)|SOQL_EXECUTE_END|[49]|Rows:1
16:25:15.8 (1278087443)|HEAP_ALLOCATE|[49]|Bytes:8
16:25:15.8 (1278113162)|HEAP_ALLOCATE|[49]|Bytes:524
16:25:15.8 (1278151757)|HEAP_ALLOCATE|[49]|Bytes:8
16:25:15.8 (1278378087)|HEAP_ALLOCATE|[49]|Bytes:651
16:25:15.8 (1278413071)|HEAP_ALLOCATE|[49]|Bytes:658
16:25:15.8 (1278443969)|USER_DEBUG|[49]|DEBUG|HERE2: (Account:{Id=0014E00000BAA5FQAX, IsDeleted=false, Name=Prasad Household, RecordTypeId=0124E0000004PsOQAU, BillingStreet=Bill1, BillingCity=Bill City, BillingState=State, BillingPostalCode=Postal, BillingCountry=UK, BillingAddress=API address [ Bill1, Bill City, State, Postal, UK, null, null, null, null, null], ShippingAddress=null, OwnerId=0054E000000L2viQAC, CreatedDate=2016-06-16 14:51:04, CreatedById=0054E000000L2viQAC, LastModifiedDate=2016-08-10 12:49:52, LastModifiedById=0054E000000L2p6QAC, SystemModstamp=2016-08-10 12:49:52, LastViewedDate=2016-08-10 14:43:09, IsPartner=false, IsCustomerPortal=true})
16:25:15.8 (1278457800)|STATEMENT_EXECUTE|[50]
16:25:15.8 (1288020530)|HEAP_ALLOCATE|[50]|Bytes:36
16:25:15.8 (1288035968)|HEAP_ALLOCATE|[50]|Bytes:159
16:25:15.8 (1288039088)|HEAP_ALLOCATE|[50]|Bytes:147
16:25:15.8 (1288069088)|METHOD_ENTRY|[1]|01p4E000000D3mS|Util.Util()
16:25:15.8 (1288073885)|STATEMENT_EXECUTE|[1]
16:25:15.8 (1288095397)|ENTERING_MANAGED_PKG|XXXXXX
16:25:15.8 (1288135086)|METHOD_EXIT|[1]|Util
16:25:15.8 (1288197449)|METHOD_ENTRY|[50]|01p4E000000D3mS|XXXXXX.Util.getSObjects(Set<Id>)
16:25:15.8 (1288210369)|ENTERING_MANAGED_PKG|XXXXXX
16:25:15.8 (1289170040)|ENTERING_MANAGED_PKG|XXXXXX
16:25:15.8 (1308239962)|SOQL_EXECUTE_BEGIN|[30]|Aggregations:0|SELECT Id,IsDeleted,MasterRecordId,Name,Type,RecordTypeId,ParentId,BillingStreet,BillingCity,BillingState,BillingPostalCode,BillingCountry,BillingAddress,ShippingStreet,ShippingCity,ShippingState,ShippingPostalCode,ShippingCountry,ShippingAddress,Phone,Fax,Website,Sic,Industry,AnnualRevenue,NumberOfEmployees,Ownership,TickerSymbol,Description,Rating,Site,OwnerId,CreatedDate,CreatedById,LastModifiedDate,LastModifiedById,SystemModstamp,LastActivityDate,LastViewedDate,IsPartner,IsCustomerPortal FROM Account Where Id IN :p_Ids
16:25:15.8 (1309713440)|METHOD_EXIT|[50]|01p4E000000D3mS|XXXXXX.Util.getSObjects(Set<Id>)
16:25:15.8 (1309785853)|VARIABLE_SCOPE_BEGIN|[43]|Ex|Exception|true|false
16:25:15.8 (1309879374)|VARIABLE_ASSIGNMENT|[43]|Ex|"common.apex.runtime.impl.ExecutionException: No such column 'BillingAddress' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names."|0x1a7353e4

As you can see, the code in the managed package does the same SOQL select, but fails.

Note that this managed package works fine in other orgs

I have tried raising a case with Salesforce, but was told it was a "Developer Support Issue".

Thanks,

Carl







 
  • August 11, 2016
  • Like
  • 0
If I create a webservice method in Apex code is there any way that I can use client certificates to autheticate the inbound web service calls?

For example, suppose I have the following class:
 
global class MyWebService {
	    webService static Id makeContact(String lastName, Account a) {
	        Contact c = new Contact(lastName = 'Weissman', AccountId = a.Id);
	        insert c;
	        return c.id;
	    }
}
Obviously, if I enable this in Sites, then someone could call this method from outside of Salesforce.  If this web service was hosted in my own web server, I could require all clients to provide a certificate (two-way SSL).  Is there any way that I do the same for my web service in Salesforce?

Regards,

Carl
 
  • April 22, 2016
  • Like
  • 0
Hello.

I have a batch process which does some clean up in the finish(...) method.  However, if the user aborts the job (e.g. they go to the list of Apex jobs and click "Abort"), this code is not executed.

I was wondering if there was any way to handle the abort event so that my clean up code is still called?

Thanks,

Carl
 
  • November 26, 2015
  • Like
  • 0
Hello.

I have a class that I use as a wrapper around an SObject:
 
global abstract with sharing class BaseDataObject implements IDataObject {  

	private SObject m_Record;
	
	global BaseDataObject (SObject p_Record) {
		setRecord(p_Record);
	}

	global BaseDataObject () {
	}
	
	global virtual SObject getRecord() {
		return m_Record;
	}

	global virtual void setRecord(SObject p_Record) {
		m_Record = p_Record;
	}
	
	global virtual String getId() {
		return m_Record.id;
	}

	.
	.
	.
}

This class is held in a managed package which I have installed in another dev org, where I have another class that extends that class, e.g.
 
global with sharing class Example extends PKG.BaseDataObject {

	.
	.
	.

}

I then try to use this class, the performance is awful.  For example, if I do this:
 
Example ex = new Example(new Test__c());

ex.Id();

The call to "ex.Id()" takes (according to Salesforce's profiler) about 0.12 milliseconds.  Any other call that involves accessing the m_Record member variable seems to take equally long.

Why is this so slow and is there anything that can be done to speed it up?

Thanks,

Carl




 
  • October 14, 2015
  • Like
  • 0
Hello.

I have written a batch process and it keeps failing with "Apex CPU time limit exceeded".

I used the Developer Console to profile the batch process and I am finding that the problem is with Apex constructors.

My batch contains 1000 records and I am wrapping each record in an Apex class.  The constructor for each class instance is taking at least 0.20 (milliseconds, I presume - although the Developer Console isn't clear).

This is a substantial chunk of the processing time.  Now, my constructor isn't doing any processing, beyond storing the record passed in as an argument.

Can anyone suggest why the constructor is soaking up so much time and what I can do about it?

Thanks,

Carl


 
  • October 12, 2015
  • Like
  • 0
Hello.

I don't have much experience with developing approval rules, and I am wondering if the following is possible.

I have a custom object with an approval process.  It works fine up to the point that it gets to the approver.  At this point, I want to force the approver to set a particular field within the object before they can approve the record.

I tried putting a condition in the "Approval Steps" section, but it is evaluated before the record gets to the approver.

I had also tried adding a validation rule, to prevent the record being saved in an approved state without this field being set, but the approval process seemed to ignore the validation rule.

Thanks,

Carl
  • September 14, 2015
  • Like
  • 0
Hello.

I have two dev orgs on EU5.  Since yesterday, I have been unable to edit any Apex code on either org using Eclipse because it takes at least 5 minutes to save.

I have tried other suggestions on the forum (such as only including certain bits of metadata in the Force.com project, but to no avail.

It does not appear to affect all orgs, as I am able to edit files using Eclipse in orgs hosted elsewhere.

Regards,

Carl
  • June 17, 2015
  • Like
  • 3
Hello.

Is it possible for a trigger to run more than once concurrently?
 
trigger AfterInsert on A__c (after insert) {

	    Set<Id> ids = new Set<Id>();

	    for (A__c a : Trigger.new) {
	        if (a.Link__c!=null) {
	            ids.add(a.Link__c);
	        }
	    }

	    Map<Id, B__c> bs = new Map<Id, B__c>([ Select id, total__c, number__c From B__c Where id in :ids]);
	    for (A__c a : Trigger.new) {
	        B__c b = bs.get(a.Link__c);
	        b.Number__c++;
	        b.Total__c = b.Total__c + a.Amount__c;
	    }
	 
	    update bs.values();
}
In the above example, after I insert an A__c record, the above trigger runs and looks for the B__c record that the A__c record was linked to and updates some fields in it.

If I insert two A__c records very close together which are both linked to the same B__c record, is it possible that the above trigger could run twice concurrently, once processing the first record and once processing the second record, so the change to the B__c record made by the first trigger run is overwritten by the second trigger run?

If so, should I actually select B__c FOR UPDATE, to prevent this happening?

Regards,

Carl

 
  • May 13, 2015
  • Like
  • 0
Hello.

I have a very odd situation. 

I have some code that makes a web service call and then inserts a record based on the result of this call.  The insert causes an after-insert trigger to run that updates a running-total amount field in a related record (it isn't a master-detail relationship, so can't use a rollup field).

This code has been installed as a managed package on various customer's orgs and works ok.

However, on one customer's org something strange happened.  The user invoked the functionality, but two identical records were created (down to having the same created timestamp).  But, the trigger appears to have only run once, because the total field in the related record only reflects a single update.

This leaves me with two possibilities:

1) Everything worked as expected, but the trigger ran twice in parallel, meaning that one update overwrote the other update
2) Salesforce has a bug that causes duplicate records to be created without any other effect.

Any thoughts?

Regards,

Carl

 
  • May 08, 2015
  • Like
  • 0
Hello.

I have a set of Apex classes which have unit tests.  The classes all save ok, but if I try to run the unit tests from within Eclipse, I get back "Method does not exist or incorrect signature".  However, if I run the unit tests from Salesforce, it all works ok.

Any ideas?

Thanks,

Carl
  • April 08, 2015
  • Like
  • 0
Hi.

I'm trying to write some Apex code to make sure I don't run into any govenor limits.  One of the limits is described as "Maximum number of Apex classes scheduled concurrently", limited to 100.

Presumably I need to look in AsyncApexJob, but what exactly should I be looking for?  All records with a status of Queued, Processing, Preparing and Holding?

Thanks,

Carl
  • April 07, 2015
  • Like
  • 0
Hi,

I have two interfaces, called A and B and I want to create a third interface, called C, that extends both of these, e.g.
global interface C extends A, B {
 
}

However, it isn't valid.  Have I missed something or does Salesforce not allow this?

Thanks,

Carl
  • March 20, 2015
  • Like
  • 0
Hi,

I have two interfaces, called A and B and I want to create a third interface, called C, that extends both of these, e.g.
 
global interface C extends A, B {

}
However, it isn't valid.  Have I missed something or does Salesforce not allow this?

Thanks,

Carl
 
  • March 18, 2015
  • Like
  • 0
Hello.

I have written a Java client that uses the metadata API in order to update the user profiles in an org.  I am able, for example, to change the tab visibility on the profiles.  However, when I try to change the object permissions for one of my custom objects on the user profile, using
 
ProfileObjectPermissions [] pers = new ProfileObjectPermissions[] { new ProfileObjectPermissions(Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, "MY_CUSTOM_OBJECT__C", Boolean.FALSE), ... };
p.setObjectPermissions(pers);

When I update the metadata, no errors are returned, but the permissions on the user profile for the object remain unchanged.

Any idea what I am missing?

Thanks,

Carl



 
  • January 26, 2015
  • Like
  • 0
Hello.

I have two dev orgs on EU5.  Since yesterday, I have been unable to edit any Apex code on either org using Eclipse because it takes at least 5 minutes to save.

I have tried other suggestions on the forum (such as only including certain bits of metadata in the Force.com project, but to no avail.

It does not appear to affect all orgs, as I am able to edit files using Eclipse in orgs hosted elsewhere.

Regards,

Carl
  • June 17, 2015
  • Like
  • 3
Hello.

I have a managed package that I install into customers' orgs.  The customers then create a Site which needs to access some of the custom objects in my managed package.  They set up the Guest User to have permission to read and modify the necessar custom objects.  However, at this point, although the objects are readable, some of the fields within those objects are not.  Salesforce seems to randomly decide which fields are accessible by default.

Is there some way to tell Salesforce which fields should be readable or can someone explain how Salesforce determines which fields are readable by default for a Site Guest user?

Regards,

Carl
 
  • June 13, 2017
  • Like
  • 0
Hello.

I have a managed package that is build on another managed package.  In particular I have interfaces in one managed package that extend (global) interfaces in the other managed package (e.g.
 
MANAGED PACKAGE A:

global interface A {

    void A();
}


MANAGED PACKAGE B:

global interface B extends A.A {

}
)

Normally this doesn't cause a problem, but recently I tried to install my managed package in an org and the install failed saying the method A() didn't exist in interface B, which clearly it does.

I got around this by changing my code to explicitly reference interface A rather than interface B, e.g.
 
ORIGINAL CODE:

B b = ....

b.A();




NEW CODE:

B b = ...

A a = (A)b;
a.A();


This got around the problem, but once I had uploaded a new version of managed package B, some of the unit tests started failing with the error:
 
Dynamic query yields incompatible SObject type B.B for loop variable of type A.A
These unit tests worked before, but it seems that Salesforce has go in a mess.

Can anyone offer a workaround?

Regards,

Carl




 
  • August 12, 2016
  • Like
  • 0
Hello.

I have a customer's org into which I have installed a managed package.  On the org is some Apex code that calls a method in the managed package.  One of the things that the method does is make a SOQL select statement, but this fails saying "No such column".  However, if I run exactly the same SOQL statement outside of the managed package, it works.

Here is a sample of the code:
 
System.debug('HERE2: ' + [SELECT BillingAddress,ShippingStreet,ShippingCity,ShippingState,ShippingPostalCode,ShippingCountry,ShippingAddress,Phone,Fax,Website,Sic,Industry,AnnualRevenue,NumberOfEmployees,Ownership,TickerSymbol,Description,Rating,Site,OwnerId,CreatedDate,CreatedById,LastModifiedDate,LastModifiedById,SystemModstamp,LastActivityDate,LastViewedDate,IsPartner,IsCustomerPortal FROM Account Where Id in :setaccountId]);
Account member = (Account)(XXXXXXX.Util.getSObjects(setAccountId)[0]);

This is the debug log:
 
16:25:15.8 (1244514753)|SOQL_EXECUTE_BEGIN|[49]|Aggregations:0|SELECT Id, IsDeleted, MasterRecordId, Name, Type, RecordTypeId, ParentId, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry, BillingAddress, ShippingStreet, ShippingCity, ShippingState, ShippingPostalCode, ShippingCountry, ShippingAddress, Phone, Fax, Website, Sic, Industry, AnnualRevenue, NumberOfEmployees, Ownership, TickerSymbol, Description, Rating, Site, OwnerId, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, LastActivityDate, LastViewedDate, IsPartner, IsCustomerPortal FROM Account WHERE Id = :tmpVar1
16:25:15.8 (1278032882)|SOQL_EXECUTE_END|[49]|Rows:1
16:25:15.8 (1278087443)|HEAP_ALLOCATE|[49]|Bytes:8
16:25:15.8 (1278113162)|HEAP_ALLOCATE|[49]|Bytes:524
16:25:15.8 (1278151757)|HEAP_ALLOCATE|[49]|Bytes:8
16:25:15.8 (1278378087)|HEAP_ALLOCATE|[49]|Bytes:651
16:25:15.8 (1278413071)|HEAP_ALLOCATE|[49]|Bytes:658
16:25:15.8 (1278443969)|USER_DEBUG|[49]|DEBUG|HERE2: (Account:{Id=0014E00000BAA5FQAX, IsDeleted=false, Name=Prasad Household, RecordTypeId=0124E0000004PsOQAU, BillingStreet=Bill1, BillingCity=Bill City, BillingState=State, BillingPostalCode=Postal, BillingCountry=UK, BillingAddress=API address [ Bill1, Bill City, State, Postal, UK, null, null, null, null, null], ShippingAddress=null, OwnerId=0054E000000L2viQAC, CreatedDate=2016-06-16 14:51:04, CreatedById=0054E000000L2viQAC, LastModifiedDate=2016-08-10 12:49:52, LastModifiedById=0054E000000L2p6QAC, SystemModstamp=2016-08-10 12:49:52, LastViewedDate=2016-08-10 14:43:09, IsPartner=false, IsCustomerPortal=true})
16:25:15.8 (1278457800)|STATEMENT_EXECUTE|[50]
16:25:15.8 (1288020530)|HEAP_ALLOCATE|[50]|Bytes:36
16:25:15.8 (1288035968)|HEAP_ALLOCATE|[50]|Bytes:159
16:25:15.8 (1288039088)|HEAP_ALLOCATE|[50]|Bytes:147
16:25:15.8 (1288069088)|METHOD_ENTRY|[1]|01p4E000000D3mS|Util.Util()
16:25:15.8 (1288073885)|STATEMENT_EXECUTE|[1]
16:25:15.8 (1288095397)|ENTERING_MANAGED_PKG|XXXXXX
16:25:15.8 (1288135086)|METHOD_EXIT|[1]|Util
16:25:15.8 (1288197449)|METHOD_ENTRY|[50]|01p4E000000D3mS|XXXXXX.Util.getSObjects(Set<Id>)
16:25:15.8 (1288210369)|ENTERING_MANAGED_PKG|XXXXXX
16:25:15.8 (1289170040)|ENTERING_MANAGED_PKG|XXXXXX
16:25:15.8 (1308239962)|SOQL_EXECUTE_BEGIN|[30]|Aggregations:0|SELECT Id,IsDeleted,MasterRecordId,Name,Type,RecordTypeId,ParentId,BillingStreet,BillingCity,BillingState,BillingPostalCode,BillingCountry,BillingAddress,ShippingStreet,ShippingCity,ShippingState,ShippingPostalCode,ShippingCountry,ShippingAddress,Phone,Fax,Website,Sic,Industry,AnnualRevenue,NumberOfEmployees,Ownership,TickerSymbol,Description,Rating,Site,OwnerId,CreatedDate,CreatedById,LastModifiedDate,LastModifiedById,SystemModstamp,LastActivityDate,LastViewedDate,IsPartner,IsCustomerPortal FROM Account Where Id IN :p_Ids
16:25:15.8 (1309713440)|METHOD_EXIT|[50]|01p4E000000D3mS|XXXXXX.Util.getSObjects(Set<Id>)
16:25:15.8 (1309785853)|VARIABLE_SCOPE_BEGIN|[43]|Ex|Exception|true|false
16:25:15.8 (1309879374)|VARIABLE_ASSIGNMENT|[43]|Ex|"common.apex.runtime.impl.ExecutionException: No such column 'BillingAddress' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names."|0x1a7353e4

As you can see, the code in the managed package does the same SOQL select, but fails.

Note that this managed package works fine in other orgs

I have tried raising a case with Salesforce, but was told it was a "Developer Support Issue".

Thanks,

Carl







 
  • August 11, 2016
  • Like
  • 0
Hello.

I have a class that I use as a wrapper around an SObject:
 
global abstract with sharing class BaseDataObject implements IDataObject {  

	private SObject m_Record;
	
	global BaseDataObject (SObject p_Record) {
		setRecord(p_Record);
	}

	global BaseDataObject () {
	}
	
	global virtual SObject getRecord() {
		return m_Record;
	}

	global virtual void setRecord(SObject p_Record) {
		m_Record = p_Record;
	}
	
	global virtual String getId() {
		return m_Record.id;
	}

	.
	.
	.
}

This class is held in a managed package which I have installed in another dev org, where I have another class that extends that class, e.g.
 
global with sharing class Example extends PKG.BaseDataObject {

	.
	.
	.

}

I then try to use this class, the performance is awful.  For example, if I do this:
 
Example ex = new Example(new Test__c());

ex.Id();

The call to "ex.Id()" takes (according to Salesforce's profiler) about 0.12 milliseconds.  Any other call that involves accessing the m_Record member variable seems to take equally long.

Why is this so slow and is there anything that can be done to speed it up?

Thanks,

Carl




 
  • October 14, 2015
  • Like
  • 0
Hello.

I have written a batch process and it keeps failing with "Apex CPU time limit exceeded".

I used the Developer Console to profile the batch process and I am finding that the problem is with Apex constructors.

My batch contains 1000 records and I am wrapping each record in an Apex class.  The constructor for each class instance is taking at least 0.20 (milliseconds, I presume - although the Developer Console isn't clear).

This is a substantial chunk of the processing time.  Now, my constructor isn't doing any processing, beyond storing the record passed in as an argument.

Can anyone suggest why the constructor is soaking up so much time and what I can do about it?

Thanks,

Carl


 
  • October 12, 2015
  • Like
  • 0
Hello.

I don't have much experience with developing approval rules, and I am wondering if the following is possible.

I have a custom object with an approval process.  It works fine up to the point that it gets to the approver.  At this point, I want to force the approver to set a particular field within the object before they can approve the record.

I tried putting a condition in the "Approval Steps" section, but it is evaluated before the record gets to the approver.

I had also tried adding a validation rule, to prevent the record being saved in an approved state without this field being set, but the approval process seemed to ignore the validation rule.

Thanks,

Carl
  • September 14, 2015
  • Like
  • 0
Hello.

Is it possible for a trigger to run more than once concurrently?
 
trigger AfterInsert on A__c (after insert) {

	    Set<Id> ids = new Set<Id>();

	    for (A__c a : Trigger.new) {
	        if (a.Link__c!=null) {
	            ids.add(a.Link__c);
	        }
	    }

	    Map<Id, B__c> bs = new Map<Id, B__c>([ Select id, total__c, number__c From B__c Where id in :ids]);
	    for (A__c a : Trigger.new) {
	        B__c b = bs.get(a.Link__c);
	        b.Number__c++;
	        b.Total__c = b.Total__c + a.Amount__c;
	    }
	 
	    update bs.values();
}
In the above example, after I insert an A__c record, the above trigger runs and looks for the B__c record that the A__c record was linked to and updates some fields in it.

If I insert two A__c records very close together which are both linked to the same B__c record, is it possible that the above trigger could run twice concurrently, once processing the first record and once processing the second record, so the change to the B__c record made by the first trigger run is overwritten by the second trigger run?

If so, should I actually select B__c FOR UPDATE, to prevent this happening?

Regards,

Carl

 
  • May 13, 2015
  • Like
  • 0
Hello.

I have a very odd situation. 

I have some code that makes a web service call and then inserts a record based on the result of this call.  The insert causes an after-insert trigger to run that updates a running-total amount field in a related record (it isn't a master-detail relationship, so can't use a rollup field).

This code has been installed as a managed package on various customer's orgs and works ok.

However, on one customer's org something strange happened.  The user invoked the functionality, but two identical records were created (down to having the same created timestamp).  But, the trigger appears to have only run once, because the total field in the related record only reflects a single update.

This leaves me with two possibilities:

1) Everything worked as expected, but the trigger ran twice in parallel, meaning that one update overwrote the other update
2) Salesforce has a bug that causes duplicate records to be created without any other effect.

Any thoughts?

Regards,

Carl

 
  • May 08, 2015
  • Like
  • 0
Hello.

I have a set of Apex classes which have unit tests.  The classes all save ok, but if I try to run the unit tests from within Eclipse, I get back "Method does not exist or incorrect signature".  However, if I run the unit tests from Salesforce, it all works ok.

Any ideas?

Thanks,

Carl
  • April 08, 2015
  • Like
  • 0
Hi.

I'm trying to write some Apex code to make sure I don't run into any govenor limits.  One of the limits is described as "Maximum number of Apex classes scheduled concurrently", limited to 100.

Presumably I need to look in AsyncApexJob, but what exactly should I be looking for?  All records with a status of Queued, Processing, Preparing and Holding?

Thanks,

Carl
  • April 07, 2015
  • Like
  • 0
Hi,

I have two interfaces, called A and B and I want to create a third interface, called C, that extends both of these, e.g.
global interface C extends A, B {
 
}

However, it isn't valid.  Have I missed something or does Salesforce not allow this?

Thanks,

Carl
  • March 20, 2015
  • Like
  • 0
Hello.

I have a production org that contains a managed package that has had numerous versions created, some of which have been installed and some of which have been skipped.

At some point, a piece of Apex code was created in the org that used the managed package, tieing it to the version of the managed package that was installed at the time.

I am now in the position that I need to update that code, so I have created a sandbox to make my changes in.  However, when I try to save that code, I get "The specified Package Version number does not exist for that Package ...", even though I haven't changed any of the metadata.

Just to explain in a bit more detail, assume that the first version of the managed package that was installed in the production org was 1.10.  This was subsequently updated to version 1.20.  At that point the Apex code was created.  The managed package was then updated to version 1.30, but the code was left unchanged, tied to version 1.20.

I now create a sandbox and try to edit the code, but it complains that version 1.20 does not exist.

Unfortunately, I need to edit the code, but keep it using version 1.20 of the package.  Is that possible?

Thanks,

Carl

 
  • December 18, 2014
  • Like
  • 0
Hello.

I'm trying to figure out how I can find out the URL for a particular page hosted in a Salesforce Site, using the metadata API.

I know that the url should be something like "https://AAA-BBB.CCC.force.com/DDD/Page_Name, where AAA is the sandbox name, BBB is the site name, CCC is the Salesforce host and DDD is the site path.

I have obtained the CustomSite metadata for the Site.  According to the documentation, the getSubdomain() method should give me "AAA-BBB.CCC.force.com".  However, instead it just gives me "BBB".

Is the documentation wrong?  If so, how do I generate the full URL for the page?
  • December 04, 2014
  • Like
  • 0
Hello

I have an update trigger that looks to see if a particular field has changed in the trigger records.  If the value has changed, the old value is added to a set.

After all the records have been checked, I end up with a set of up to 200 values (assuming the trigger has handled 200 updated records, for which all records have had the field changed and the original value for all the records were different).

I now want to see if there are any other records that still have each of those original values.

For example, suppose that the field in question is a string and that two records have been updated.  For the first record, the field has changed from 'A' to 'B' and the second record the field has changed from 'C' to 'D'.  At the end of the trigger, I want to see if there are any records that have a field value of 'A' or 'C'.

The obvious solution is to do [ Select X__c from A__c Where X__c In ('A', 'C') ]

However this may return thousands of records.

The alternative is to run [ Select X__c From A__c Where X__c = 'A' Limit 1] then [ Select X__c From A__c Where X__c = 'C' Limit 1], but obviously if there are 200 different values to check, this solution isn't practical.

Is there an alternative approach that I am missing?

Thanks,

Carl
 
  • November 08, 2014
  • Like
  • 0