---
schema_version: "1"
id: dd131bb47561b049308649d4c23de1f43f3e34debceda5b0af3d6e2d636c2671
title: GUIDs Performance - Inspect and Modify Custom Code
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/comms_guids_performance___inspect_and_modify_custom_code.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.comms_guids_performance___inspect_and_modify_custom_code.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 4724b47cb9674b98af32c2680b90489512ff90b122d33affaa5e73c5ee609ee6
description: You can inspect and adapt custom Apex code to handle the new values present in the ParentItemId__c and RootItemId__c fields of the Asset, OrderItem, OpportunityLineItem, and QuoteLineItem SObjects.
products:
  - Communications
  - Media
  - Energy and Utilities
release: "264"
---
# GUIDs Performance - Inspect and Modify Custom Code

You can inspect and adapt custom Apex code to handle the new values present in the ParentItemId\_\_c and RootItemId\_\_c fields of the Asset, OrderItem, OpportunityLineItem, and QuoteLineItem SObjects.

## Tips for Modifying Custom Code for Specific Cases

It is not possible to enumerate all the use cases and adjustments here for the new values found in the ParentItemId\_\_c and RootItemId\_\_c fields. This section lists some of the more likely scenarios and suggests strategies for adjustment.

**Case 1: ParentItemId\_\_c fetches the parent SObject**

Here is an example of such a query as it may exist in your current code:

```
OpportunityLineItem parentOppLineItem = [
    SELECT Id, UnitPrice, Product2.Name 
      FROM OpportunityLineItem 
      WHERE Id=:childOppLineItem.vlocity_cmt__ParentItemId__c];
```

You can adjust this example to work with GUIDs, as follows:

```
OpportunityLineItem parentOppLineItem;
if (containerIsUsingGuids)
{
    // using guids, ParentItemId__c is comparable to
    // AssetReferenceId__c
    parentOppLineItem = [
        SELECT Id, UnitPrice, Product2.Name
          FROM OpportunityLineItem
         WHERE vlocity_cmt__AssetReferenceId__c =         
         :childOppLineItem.vlocity_cmt__ParentItemId__c];
}
else
{
    // using legacy salesforce ids. ParentItemId__c is comparable to Id.
    parentOppLineItem = [
        SELECT Id, UnitPrice, Product2.Name
          FROM OpportunityLineItem
         WHERE Id=:childOppLineItem.vlocity_cmt__ParentItemId__c];
}
```

This example assumes that the `containerIsUsingGuids` value is determined by logic similar to the `isContainerUsingGuids()` method supplied above.

**Case 2: RootItemId\_\_c identifies line items within a hierarchy having the same root**

RootItemId\_\_c is used as input to the query for selecting the line items in the hierarchy, but that case is similar enough to the previous case (using ParentItemId\_\_c) that it’s not repeated here. Instead, consider the case where all line items in the container have already been fetched into memory and the RootItemId\_\_c value collects the line items belonging to a single hierarchy.

The existing code to collect the hierarchy might look something like the following example, which assumes that a previously identified rootAsset and a list of all assets in the container are supplied as input.

```
List<Asset> allAssetsInHierarchy = new List<Asset>();
for (Asset currentAsset : allAssetsInContainer)
{
    if (currentAsset.vlocity_cmt_RootItemId__c == rootAsset.Id)
    {
        allAssetsInHierarchy.add(currentAsset);
    }
}
```

The code identifies the assets in the hierarchy by comparing the RootItemId\_\_c value to the Salesforce ID of the known root. This does not always work when the GUID feature is enabled.

Here is how the code might look after adjusting for the GUID performance feature. It has the same input assumptions and leverages the isRootLineItemUsingGuids method defined above.

```
Boolean usingGUIDs = isRootLineItemUsingGuids(rootAsset);
List<Asset> allAssetsInHierarchy = new List<Asset>();
for (Asset currentAsset : allAssetsInContainer)
{
    if (usingGUIDs)
    {
        if (currentAsset.vlocity_cmt__RootItemId__c == 
            rootAsset.vlocity_cmt__AssetReferenceId__c)
        {          
           allAssetsInHierarchy.add(currentAsset);
        }
    }
    else
    {
        if (currentAsset.vlocity_cmt_RootItemId__c ==
            rootAsset.Id)
        {
            allAssetsInHierarchy.add(currentAsset);
        }
    }
}
```

- **[Recommended Approach for Identifying Problem Areas](https://help.salesforce.com/s/articleView?id=ind.comms_recommended_approach_for_identifying_problem_areas.htm&release=264.0.0&type=5)**  
    Salesforce recommends you do a code inspection before testing to identify problems in custom-code. Issues regarding custom-code sensitivity to the data model changes are not always readily apparent and may pass a cursory test.
- **[Guidelines for Adapting References to RootItemId\_\_c and ParentItemId\_\_c](https://help.salesforce.com/s/articleView?id=ind.comms_guidelines_for_adapting_references_to_rootitemid__c_and_parentitemid__c.htm&release=264.0.0&type=5)**  
    If the checks described in the previous section identify areas that need modification, then you need to adjust the custom code. The specific cases that need adjusting are those in which the values taken from the `RootItemId__c` and `ParentItemd__c` fields are treated as Salesforce IDs. If the values are treated strictly as strings and never compared to any other Salesforce ID value, then the code may still execute without modification.