function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Manish MangalManish Mangal 

How to Update _soupEntryId ?

Manish MangalManish Mangal

export const upsertSoupEntries = (storeConfig, soupName, entries, successCB, errorCB) => {
var storeConfig = checkFirstArg(storeConfig);
upsertSoupEntriesWithExternalId(storeConfig, soupName, entries, "_soupEntryId", successCB, errorCB);
};

export var upsertSoupEntriesWithExternalId = (storeConfig, soupName, entries, externalIdPath, successCB, errorCB) => {
var storeConfig = checkFirstArg(storeConfig);
exec(successCB, errorCB, "upsertSoupEntries", {"soupName": soupName, "entries": entries, "externalIdPath": externalIdPath, "isGlobalStore": storeConfig.isGlobalStore,"storeName":storeConfig.storeName});
};

I am using this methods Please suggest me how we can update _soupEntryId ?

SwethaSwetha (Salesforce Developers) 
HI Manish,
Your ask looks related to Mobile SDK. In Salesforce Mobile SDK, the _soupEntryId field is a system-generated field that uniquely identifies each entry in the soup. Since it is a system-generated field, you cannot update its value directly. However, you can update the value of _soupEntryId indirectly by performing an upsert operation with an external ID.

Related; https://developer.salesforce.com/docs/atlas.en-us.mobile_sdk.meta/mobile_sdk/offline_functions.htm

You can reach out to Mobile SDK page on https://trailhead.salesforce.com/trailblazer-community/groups/0F94S000000kH0HSAU?tab=discussion&sort=LAST_MODIFIED_DATE_DESC incase of any followup queries on your ask.

You can also post to tag https://salesforce.stackexchange.com/questions/tagged/mobilesdk

If this information helps, please mark the answer as best. Thank you
Manish MangalManish Mangal

Thanks @swetha for the quick response, i appricate if you could help me on  one more query related to the same.

How to Generate _soupEntryId  for react-native ?

https://developer.salesforce.com/forums?id=9062I000000DP00QAG
Thanks in advanced.

Joe L. ThompsonJoe L. Thompson
The _soupEntryId is a system-generated unique identifier for each record in SmartStore, and it cannot be updated directly. Instead, when you want to update a record in SmartStore, you should use the _soupEntryId to reference the record and update its fields.
In the react-native-smartstore package, you can use the upsertSoupEntriesWithExternalId method to update records based on an external identifier. This method uses the external identifier to find the matching record in the SmartStore and updates its fields.
Here's an example of how you can use the upsertSoupEntriesWithExternalId method to update a record in SmartStore:
 
import { SmartStore } from 'react-native-smartstore';

// Define your record object with the updated values
const updatedRecord = {
  _soupEntryId: '12345', // use the existing _soupEntryId to reference the record
  firstName: 'John',
  lastName: 'Doe',
  email: 'johndoe@example.com'
};

// Update the record in SmartStore based on its external ID
SmartStore.upsertSoupEntriesWithExternalId('mySoup', [updatedRecord], '_soupEntryId', (result) => {
  console.log('Record updated successfully:', result);
}, (error) => {
  console.error('Error updating record:', error);
});

In this example, mySoup is the name of the soup where the record is stored. The upsertSoupEntriesWithExternalId method updates the record in the SmartStore based on its _soupEntryId.
Note that when using the upsertSoupEntriesWithExternalId method, the external ID path (in this case, '_soupEntryId') should match the path of the external ID field for the soup. By default, SmartStore uses the _soupEntryId field as the external ID field for all soups, so this is typically the value you should use for the external ID path.
Santosh Joshi 11Santosh Joshi 11
Hi Manish,
Based on the code you provided, it looks like you're using methods to upsert (update or insert) entries into a SmartStore soup, which is essentially a local database for mobile apps.

The "upsertSoupEntries" function is calling the "upsertSoupEntriesWithExternalId" function with the "_soupEntryId" parameter as the external ID path. This means that if an entry with that external ID already exists in the soup, it will be updated with the new entry data, otherwise a new entry will be created with that external ID.

To update the "_soupEntryId" field specifically, you need to include it as a field in the entries you're upserting, and make sure the external ID value you're using for each entry is unique within the soup.

For example, if you have an entry object like this:
{ "Name": "John Doe",
"Email": "johndoe@example.com",
"_soupEntryId": "12345"
}

When you upsert this entry into the soup, it will either update the existing entry with "_soupEntryId" equal to "12345", or create a new entry with that ID if it doesn't already exist. If you want to update the "_soupEntryId" field itself, you can simply change the value in the entry object before upserting it.

I hope this helps! Let me know if you have any further questions.
olivia alisonolivia alison
The _soupEntryId field is used by the Salesforce Mobile SDK for database indexing purposes and is automatically generated when a record is inserted into the database. It's not recommended to update the _soupEntryId field manually, as doing so can lead to data inconsistencies and unexpected behavior.
Instead, if you need to update a record, you can update the record's fields using the standard Salesforce APIs or tools such as Data Loader. The _soupEntryId field will automatically be updated by the Salesforce Mobile SDK (https://bestbabyheadphones.com/what-age-can-babies-wear-headphones/) to reflect any changes made to the record.
If you need to delete a record, you can do so using the standard Salesforce APIs or tools. The record will be deleted from both the Salesforce database and the local SmartStore database on the device.
In summary, it's not necessary to update the _soupEntryId field manually. Instead, use the standard Salesforce APIs or tools to update or delete records as needed.