I'm using $SObjectType.CurrentUser.Id to find out if the current User is the owner of the current record. The issue here is that the method is providing a 15 char user Id.

<aura:if isTrue="{!v.record.OwnerId == $SObjectType.CurrentUser.Id}">

results in false since these are the values:



Is there any easy way to cast it right there to a 18 digit? Or any other workaround so I don't have to do another server trip?


Salesforce fixed this with winter'19.


does now return 18 chars.

  • 2
    That sounds like a bug. I would rather report this to salesforce than try to work around it. You should always be getting an 18-character ID. – sfdcfox Oct 11 '18 at 16:30
  • Nasty bug, had to do a workaround for our custom filters due to this. It is so inconsistent with apex's UserInfo.getUserId() counterpart. – Raul Oct 11 '18 at 18:20
  • @sfdcfox good news, it's already fixed in winter'19 :) – Basti Oct 15 '18 at 8:58

If you need to get the OwnerId as 15 digits, you can do the truncation wherever you set record in your controller. You can either overwrite record.OwnerId, or store a separate recordOwnerId attribute. I would probably do the latter.

// somewhere wiithin your controller
component.set("v.record", someRecordData);
component.set("v.recordOwnerId", someRecordData.OwnerId.substring(0, 15));

And then you could compare:

<aura:if isTrue="{!v.recordOwnerId == $SObjectType.CurrentUser.Id}">

Or if you really want, you could create a formula to explicitly store the 15 digit OwnerId:

LEFT(OwnerId, 15)

And then you would compare to this value instead:

<aura:if isTrue="{!v.record.Owner_Id_15_Digit__c == $SObjectType.CurrentUser.Id}">
| improve this answer | |
  • well the owner is in 18 chars already, the problem is the user (it comes with 15, don't ask me why :P) – Basti Oct 11 '18 at 14:49
  • So you could just truncate in your controller wherever you retrieve record, no? – Adrian Larson Oct 11 '18 at 14:50
  • lightning data service.. But yes, I guess this is my way to go. pretty hacky though :( Actually I will just prepare a boolean in js.. – Basti Oct 11 '18 at 14:52
  • Funny, they already fixed this with winter 19 but my scratch org was still on summer... – Basti Oct 15 '18 at 8:39

Another way is you can also create a method in lightning component which will convert 15 to 18 digit


<aura:attribute name="currentUserID" type="String"
default="{!($SObjectType.CurrentUser.Id)}" access="global" />

<aura:if isTrue="{!v.recordOwnerId == currentUserID}">


convertTo18 : function(component) {
        var idParts = component.get("v.currentUserID").match(/(.{5})(.{5})(.{5})/)
        var base36 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'.split('')
        var output = []
        var outer, inner, subparts, buffer

        for(outer = 1; outer <= 3; outer++) {
            subparts = idParts[outer].split('')
            buffer = 0
            for(inner = 4; inner >= 0; inner--) {
                buffer = (buffer << 1) | (subparts[inner].match(/[A-Z]/) ? 1 : 0)

        component.set("v.currentUserID",component.get("v.currentUserID") + output.join(''));

ref: convert 15 digit Id to 18 digit Id

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.