2

In release notes for Summer'22 I found an interesting change to System class.

"Asynchronously create records for cases, leads, and custom objects. Use the createRecordAsync method in the System.Network class."

Does anybody have any additional information on what does it do? Does it start a separate job, are there limits?

Haven't found any information on it so far except this 2 lines of text.

1 Answer 1

6

From the doc,


createRecordAsync(processType, mbObject)

Asynchronously creates case, lead, and custom object records. This method collects record creation requests and processes them in batches.

Signature public static String createRecordAsync(String processType, SObject mbObject)

Parameters

processType Type: String The process you use to create records.

mbObject Type: SObject The records created for objects. Objects must be supported by the high-volume record creation.

Return Value Type: String . Returns the UUID for the record created


UPDATE:

I have these inputs from our product team:

Usecase: The createRecordAsync method should be used in the context of large-scale B2C digital experiences (aka, communities, sites, networks) which require supporting high scale of creation of the most common objects like cases, leads and custom objects. In that case, an object created using this method will be created asynchronously, by first being collected into a batch, and then created in bulk together with other creation requests. This way of creation is much more efficient and hence can support much larger throughputs of object/min. An example of such could be a microsite that collects leads, and expects a huge influx of users signing up when campaign starts. For such usecase, using this method would allow a much higher scale of leads creation than having those lead requests created one at a time, when the user submits them.

Note: The below information is taken from the upcoming help doc which is expected to be live by early June (safe harbor). This is subject to change and should not be considered the source of truth.

Guest users can create five times as many cases, leads, and custom objects when they’re collected into batches and processed asynchronously rather than one at a time. Batch processing improves performance and keeps your site moving during heavy traffic spikes.

  1. From Setup, in the Quick Find box, enter Apex Classes, and then select Apex Classes.
  2. Use this function for the Apex controller that manages the object that you want to create.

String uuid = Network.createRecordAsync('GENERIC', mycase);

  • The first parameter processType must be set to 'GENERIC'.
  • The second parameter sObject can’t be empty or null. It must contain a valid value representing a supported object.

For example, to create cases in batches:

new Case(
 mycase.Subject = 'sample case',
 mycase.Description = 'case description');

Hope this helps!

10
  • Can you please elaborate about what are the sample use case of that method or best practices?
    – kurunve
    May 5 at 12:20
  • thank you, forgot to change to 55.0 version in docs. One question, what is processType, can it be any string?
    – ytiq
    May 5 at 13:59
  • Given that it is in the Network namespace - the implication is this is used for high volume Community users - I too, look forward to seeing a use case
    – cropredy
    May 5 at 16:51
  • 1
    thanks a lot. I'll close the question, once you update the thread
    – ytiq
    May 6 at 7:28
  • 1
    thanks for a great update. Your help is much appreciated :smiley-face:
    – ytiq
    May 20 at 19:10

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.