+ Start a Discussion
Deepak GulianDeepak Gulian 

Lightning Data Service returning a weird recordId in Salesforce1 mobile app

I was learning about the Lightning Data Service from this module over trailhead, I have implemented the same as suggested, during "Save a New Record" I was just trying to fetch a "recordId" of new record using the below line of code.

var recId = result.recordId;

When I execute this code over Salesforce web, it simply returns 18 digit Record Id in the following format "a05############QAU", but If I execute the same over Salesforce1 Mobile app it returns me Record Id in this format "a05___#########AUQ".  As a result, I am not able to navigate to a newly created record in a mobile app.

I am not sure if this is a bug in Lightning or am I missing something to consider for Mobile App? Please suggest.


Raj VakatiRaj Vakati
It  could be same .. can you share the screen shot of the debuging ??? 
Deepak GulianDeepak Gulian

Hi Raj, I am able to figure this out from here (https://trailhead.salesforce.com/en/modules/lightning_data_service/units/lightning_data_service_manipulate_records).

Asynchronous Record Saving
Hypothetical situation time! So you’re using the Salesforce app, and a save attempt fails to reach the server due to connection issues. Maybe the train you’re on went into a tunnel, you accidentally roamed through that corner of the building without cell reception, or gremlins have been messing with the cell towers again. In any case, don’t worry, LDS has your back. In the event of a connection problem, Lightning Data Service stores your changes in a local cache. This is indicated by a DRAFT state in the SaveRecordResult object. A record’s DRAFT state is resolved when the connection is restored. When saving a record through LDS, the local cache isn’t updated until the save is complete. When the save is successfully completed on the server, the cache is updated to the latest version of the record from the server, and all components with a reference to that record are notified. You don’t have to worry about manually reloading the record into the cache after saving. LDS handles all the work for you.

Whenever I was trying to save a record the status is always DRAFT which means record is not committed to the server yet, that's why it was showing that wierd Record ID in logs. I am able to resolve this by unchecking this option "Enable offline create, edit, and delete in Salesforce for Android and iOS." available under "Salesforce Offline" in set up.

BTW thank you for the response :)