Loading
Feature degradation | Gmail Email delivery failureRead More
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Create Assets and Related Records

          Create Assets and Related Records

          Use the composite API to create multiple Asset records and related records, such as Asset Action, Asset Action Source, Asset State Period, Asset Relationship records.

          Resource
          https://yourInstance.salesforce.com/services/data/vXX.X/composite
          JSON Request Sample

          This sample request demonstrates how to create assets.

          {
            "allOrNone": true,
            "compositeRequest": [
              {
                "method": "POST",
                "url": "/services/data/vXX.X/sobjects/Asset",
                "referenceId": "refAsset1",
                "body": {
                  "AccountId": "{{accountId}}",
                  "Name": "InfinitraBytes Firewall",
                  "Product2Id": "{{termedProductId1}}",
                  "ContactId": "{{contactId}}",
                  "HasLifecycleManagement": true,
                  "LifecycleStartDate": "2023-04-05T00:00:00.000+0000",
                  "LifecycleEndDate": "2024-04-05T23:59:59.000+0000",
                  "CurrentMRR": 1000,
                  "CurrentQuantity": 10,
                  "TotalLifecycleAmount": 12000
                }
              },
              {
                "method": "POST",
                "url": "/services/data/vXX.X/sobjects/Asset",
                "referenceId": "refAsset2",
                "body": {
                  "AccountId": "{{accountId}}",
                  "Name": "InfinitraBytes Router",
                  "Product2Id": "{{termedProductId2}}",
                  "ContactId": "{{contactId}}",
                  "HasLifecycleManagement": true,
                  "LifecycleStartDate": "2023-05-05T00:00:00.000+0000",
                  "LifecycleEndDate": "2024-04-05T23:59:59.000+0000",
                  "CurrentMRR": 0,
                  "CurrentQuantity": 0,
                  "TotalLifecycleAmount": 5500
                }
              },
              {
                "method": "POST",
                "url": "/services/data/vXX.X/sobjects/AssetAction",
                "referenceId": "refAA1",
                "body": {
                  "AssetId": "@{refAsset1.id}",
                  "Type": "Generate",
                  "category": "Initial Sale",
                  "CategoryEnum": "Initial Sale",
                  "ActionDate": "{{currentDate}}",
                  "quantityChange": 10,
                  "mrrChange": 1000,
                  "amount": 12000,
                  "TotalInitialSaleAmount": 12000,
                  "TotalMrr": 1000
                }
              },
              {
                "method": "POST",
                "url": "/services/data/vXX.X/sobjects/AssetAction",
                "referenceId": "refAA2",
                "body": {
                  "AssetId": "@{refAsset2.id}",
                  "Type": "Generate",
                  "category": "Initial Sale",
                  "CategoryEnum": "Initial Sale",
                  "ActionDate": "{{currentDate}}",
                  "quantityChange": 5,
                  "mrrChange": 500,
                  "amount": 5500,
                  "TotalInitialSaleAmount": 5500,
                  "TotalMrr": 500
                }
              },
              {
                "method": "POST",
                "url": "/services/data/vXX.X/sobjects/AssetStatePeriod",
                "referenceId": "refASP1",
                "body": {
                  "AssetId": "@{refAsset1.id}",
                  "startDate": "2023-04-05T00:00:00.000+0000",
                  "endDate": "2024-04-05T23:59:59.000+0000",
                  "quantity": 10,
                  "amount": 0,
                  "mrr": 1000
                }
              },
              {
                "method": "POST",
                "url": "/services/data/vXX.X/sobjects/AssetStatePeriod",
                "referenceId": "refASP2",
                "body": {
                  "AssetId": "@{refAsset2.id}",
                  "startDate": "2023-05-05T00:00:00.000+0000",
                  "endDate": "2024-04-05T23:59:59.000+0000",
                  "quantity": 5,
                  "amount": 0,
                  "mrr": 500
                }
              },
              {
                "method": "POST",
                "url": "/services/data/vXX.X/sobjects/AssetActionSource",
                "referenceId": "refAAS1",
                "body": {
                  "AssetActionId": "@{refAA1.id}",
                  "transactionDate": "{{currentDate}}",
                  "adjustmentAmount": 0,
                  "productAmount": 12000,
                  "estimatedTax": 0,
                  "actualTax": 0,
                  "startDate": "2023-04-05T00:00:00.000+0000",
                  "endDate": "2024-04-05T23:59:59.000+0000",
                  "quantity": 10,
                  "ExternalReference": "ABC",
                  "ExternalReferenceDataSource": "ExtABC",
                  "ReferenceEntityItemId": "{{orderItemId1}}"
                }
              },
              {
                "method": "POST",
                "url": "/services/data/vXX.X/sobjects/AssetActionSource",
                "referenceId": "refAAS2",
                "body": {
                  "AssetActionId": "@{refAA2.id}",
                  "transactionDate": "{{currentDate}}",
                  "adjustmentAmount": 0,
                  "productAmount": 5500,
                  "estimatedTax": 0,
                  "actualTax": 0,
                  "startDate": "2023-05-05T00:00:00.000+0000",
                  "endDate": "2024-04-05T23:59:59.000+0000",
                  "quantity": 5,
                  "ExternalReference": "ABC",
                  "ExternalReferenceDataSource": "ExtABC",
                  "ReferenceEntityItemId": "{{orderItemId2}}"
                }
              },
              {
                "method": "POST",
                "url": "/services/data/vXX.X/sobjects/AssetRelationship",
                "referenceId": "refAR1",
                "body": {
                  "AssetId": "@{refAsset1.id}",
                  "AssetRole": "Bundle",
                  "FromDate": "2023-05-05T00:00:00.000+0000",
                  "GroupingKey": "InfinitraBytesFirewallWithSwitch",
                  "ProductRelationshipTypeId": "{{productRelationshipType}}",
                  "RelatedAssetId": "@{refAsset2.id}",
                  "RelatedAssetRole": "BundleComponent"
                }
              }
            ]
          }

          Considerations

          Keep these considerations in mind when creating assets and their related records.

          • When migrating numerical fields, having 0 or null as the field value is an important distinction. When you amend an asset, the field values 0 and null are treated differently. If the field value is null but the system sets the value to 0, this could be treated as a field amendment and trigger certain behavior.
          • When using Asset Contract Relationship records, the lifecycle start date and lifecycle end date of the assets must be between the contract dates.

          Make sure that you migrate these records and fields.

           
          Loading
          Salesforce Help | Article