• MetaWhat
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
Interesting behavior with SOQL query.

Here is the setup.

Some_Field__c is a Text length 20.

Some_Field__c is not null

This is proven by running

SELECT Some_Field__c FROM Account  WHERE Id ='0013000000Ik1srAAB'  and Some_Field__c !=null

and it returns the row.

And

SELECT Some_Field__c FROM Account  WHERE Id ='0013000000Ik1srAAB'  and Some_Field__c = null

does not return a row.

The row is an empty string but

SELECT Some_Field__c FROM Account  WHERE Id ='0013000000Ik1srAAB'  and Some_Field__c = ''

doesnt return anything.

Also,

SELECT Some_Field__c FROM Account  WHERE Id ='0013000000Ik1srAAB'  and Some_Field__c = '%'

doesn't return anything.


This is happening on a summer 08 sandbox org.

How do I filter on the empty string?

Running into a rather frustrating problem with using the Metadata API to update a Picklist field.

The first problem is that the API requires that you provide the PickList values when performing an update even though you may not need to change the pick list values. 


Second, when you provide the PickList values (using the same syntax that works with  a create) you get an error saying  "INVALID_FIELD" error with the message "Failed to create picklist value:<picklist value>".

Code:
                CustomField cfStatus = new CustomField();

  cfStatus.setFullName("MyExistingObj.Status__c");
  cfStatus.setDescription("The Status");
  cfStatus.setType(FieldType.Picklist);
  cfStatus.setLabel("Status");
  
  Picklist pl = new Picklist();
  PicklistValue [] statusValues = new PicklistValue [] {new PicklistValue("Saved",false)};
  pl.setPicklistValues(statusValues);
  cfStatus.setPicklist(pl);

  UpdateMetadata updateMetadataStatus  = new UpdateMetadata();
  updateMetadataStatus.setMetadata(cfStatus);

  updateMetadataStatus.setCurrentName("MyExistingObj.Old_Status__c");
  
sfdc.update (new UpdateMetadata [] {updateMetadataStatus});

 
Above is the code that doesn't work.

If I change this into a create action (changing UpdateMetadata out for Metadata and calling the create) it creates the field without a problem.

I am guessing it might be something to do setting the full name on the PicklistValue object but I tried all the variations that I could think of (<custom object>.<field>.<picklist value>, <field>.<picklist value>, ect) and couldn't get it to take. 

So if it does work then I am missing something, 

Any one gotten this to work and if so any examples of what is working?


Thanks for any help. 


Interesting behavior with SOQL query.

Here is the setup.

Some_Field__c is a Text length 20.

Some_Field__c is not null

This is proven by running

SELECT Some_Field__c FROM Account  WHERE Id ='0013000000Ik1srAAB'  and Some_Field__c !=null

and it returns the row.

And

SELECT Some_Field__c FROM Account  WHERE Id ='0013000000Ik1srAAB'  and Some_Field__c = null

does not return a row.

The row is an empty string but

SELECT Some_Field__c FROM Account  WHERE Id ='0013000000Ik1srAAB'  and Some_Field__c = ''

doesnt return anything.

Also,

SELECT Some_Field__c FROM Account  WHERE Id ='0013000000Ik1srAAB'  and Some_Field__c = '%'

doesn't return anything.


This is happening on a summer 08 sandbox org.

How do I filter on the empty string?

Hi,

 

I'm getting frustrated with governor limits on triggers.  I've taken all the correct steps as per the documentation (except the "helper class" one) and it's not a case anymore of coding correctly.  It's now just a case of having a lot of data in the system.

 

In the "Force.com Cookbook" the chapter called "Avoiding Apex Governor Limits" has a beautiful example that I would like to use almost exactly as it is.  In the example, whenever an address changes on an account, a trigger updates the address onto all the contacts.

 

Now this is wonderful if you don't have too many contacts, if you only sell to small companies.  If you sell to large companies as we do and we have hundreds of sales and service contacts in a company, such a trigger will most likely hit governor limits no matter what you do.

 

What good would such a trigger be if it could only update, say, the first 100 contacts out of 500 and leave the other 400 unmodified?

 

What other magic tricks have you guys done when you've found yourself in similar situations?  Do you just say, oh well, triggers can't help us or are there some really clever ways I've not thought of?

 

I hope I can get a couple of clever tips from the experts. 

Running into a rather frustrating problem with using the Metadata API to update a Picklist field.

The first problem is that the API requires that you provide the PickList values when performing an update even though you may not need to change the pick list values. 


Second, when you provide the PickList values (using the same syntax that works with  a create) you get an error saying  "INVALID_FIELD" error with the message "Failed to create picklist value:<picklist value>".

Code:
                CustomField cfStatus = new CustomField();

  cfStatus.setFullName("MyExistingObj.Status__c");
  cfStatus.setDescription("The Status");
  cfStatus.setType(FieldType.Picklist);
  cfStatus.setLabel("Status");
  
  Picklist pl = new Picklist();
  PicklistValue [] statusValues = new PicklistValue [] {new PicklistValue("Saved",false)};
  pl.setPicklistValues(statusValues);
  cfStatus.setPicklist(pl);

  UpdateMetadata updateMetadataStatus  = new UpdateMetadata();
  updateMetadataStatus.setMetadata(cfStatus);

  updateMetadataStatus.setCurrentName("MyExistingObj.Old_Status__c");
  
sfdc.update (new UpdateMetadata [] {updateMetadataStatus});

 
Above is the code that doesn't work.

If I change this into a create action (changing UpdateMetadata out for Metadata and calling the create) it creates the field without a problem.

I am guessing it might be something to do setting the full name on the PicklistValue object but I tried all the variations that I could think of (<custom object>.<field>.<picklist value>, <field>.<picklist value>, ect) and couldn't get it to take. 

So if it does work then I am missing something, 

Any one gotten this to work and if so any examples of what is working?


Thanks for any help.