You need to sign in to do that
Don't have an account?
Matt Folger
Formula field to grab Owner built-in field
Hi, I'm trying to grab the Owner information for a custom field "Created By" so I can manipulate it to my heart's content. However, I'm unable to convert the Owner information in a text forumla field, it simply says that the field doesn't exist. Is it possible to access the Owner default field in any way so I don't have to have users input that data manually?
Here is my formula on the Account object:
'Owner is: '& Owner.FirstName & ' and Created by is: '& CreatedBy.FirstName
This will bring back on the Account page:
So the formula works, I can get the first name of both the owner and who created the record, in the UI.
Here is my Apex Query
Now if I had to use SOQL to pull it back, things would be slightly different. I filtered on the exact same ID I'm looking at in the UI.
SELECT CreatedBy.FirstName, Owner.FirstName, Id FROM Account WHERE Id = '001G0000019C9qs'
which returns:
This just has to work.
Hang on, your screenshot there.....that formula editor is to declare a default value of a text field. Please tell me that hasn't all just been about trying to set a default value
All Answers
I'm not sure I understand. Is it a custom field or a record on a custom object? Records do have owners but I don't what you would mean by an owner of a field.
Similarly, are you trying to get information about the Created By user or the owner (those are necessarily the same thing).
Chris
* Created By
* ID
* Last Modified By
* Owner
I'm trying to pull the Owner default field into a Visualforce page, but when it wasn't behaving as expected I looked it up and it appears you can't reference it like a custom field so that brings me to my question. I'm trying to just grab the Owner with something like "Formula Field = TEXT(Owner)" or whatever, no syntax seems to work, so I can manipulate that for the user's benefit.
I'm noticing now however that the Created By field is a default field, so I'll have to rename my custom field to something else if it is indeed the fact that I can't manipulate any of the default fields in this way.
Error:No such column 'CreatedBy' on entity 'Vencorr__c'. 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.
What about CreatedByID? Try using workbench to see what comes back. I just pulled a custom object quickly, and you saying that just triggered my memory.
I think it's because they are different objects so all it really stores is the ID. Someone much smarter than me can correct this if needed. OwnerId is there as well
You should then be able to use dot notation to get createdby or owner fields such as name (try OwnerId.LastName if OwnerID works)
Note: if you haven't used Workbench yet, get it! It's amazing
https://workbench.developerforce.com/
For created by (you can play around with the combinations) For owner
So I've tried this in a variety of ways:
* Tried to setup createdby.lastname and owner.lastname and owner.id and createdby.id, etc. all as either the formula's for a new TEXT forumla field called InquiredBy. I've also tried setting up this InquiredBy field as a regular TEXT field with a default value of that "formula" (createby.lastname, etc) and they all error out with the attached screenshot error message. What's the deal? How can it not know about a default field that every custom object woudl have? Is the syntax wrong or can you seriously not pull any useful data out of these default fields?
Example, if i am on account object, create a new text formula field - in the formula editor under --select field type-- account would be selected by default. But in your case i dont see any object, can you explain to me in simple terms what you are looking for?
Here is my formula on the Account object:
'Owner is: '& Owner.FirstName & ' and Created by is: '& CreatedBy.FirstName
This will bring back on the Account page:
So the formula works, I can get the first name of both the owner and who created the record, in the UI.
Here is my Apex Query
Now if I had to use SOQL to pull it back, things would be slightly different. I filtered on the exact same ID I'm looking at in the UI.
SELECT CreatedBy.FirstName, Owner.FirstName, Id FROM Account WHERE Id = '001G0000019C9qs'
which returns:
This just has to work.
Hang on, your screenshot there.....that formula editor is to declare a default value of a text field. Please tell me that hasn't all just been about trying to set a default value
Does that answer your question?
Thanks for that SQL line, I'm going to test that out!
The whole reason to begin with I'm trying to create this InquiredBy field is so I can reference it in a user-built SQL query, and it wasn't working. In thinking that I couldn't reference Owner or CreatedBy in that way I was trying to map those to a custom field so I could manipulate it however I wanted. I'll try to use that nomenclacture regarding the SQL query and see if it works!
You have to create a formula field with text return type, then you can easily refer to the created/owner fields in it. But text field with a default value is not the way to go for your case.
Worked like a charm, I entered the ".Lastname" aspect to the CreatedBy and it worked great.
Thanks! Only problem.... who do I give credit to?
=]
I'll happily take the credit :) but as long as it goes to someone and the question gets marked as solved so that it can help others I'm happy