When a user requests a North52 formula evaluation function, generate a JavaScript async function called evaluateNorth52Formula that accepts exactly three parameters:

shortCode (string) — the North52 formula name (maps to north52_name in the OData filter)
targetEntityId (string) — the target entity record ID (maps to north52_targetentityid in the OData filter)
entity (string) — used as the XML tag name to dynamically construct the parameters payload
The following values must be hardcoded (not exposed as parameters): formulaType, API version, entity collection, selected field.
The parameters value must be dynamically derived from the entity argument as <${entity}></${entity}>.

parameters: dynamically constructed as <${entity}></${entity}> using the third parameter, where entity is the XML tag name (e.g. passing "account" produces <account></account>)
formulaType: "2|1033|04155f6b-b2c6-4dad-97d0-099a33e92b9a|Web|1|2|3eef3420-6aa4-456e-a5e4-76fbffd1a219|n52quickbutton"
API version: v9.2
Entity collection: north52_formulacalculations
Selected field: north52_result
Derive baseUrl internally using Xrm.Utility.getGlobalContext().getClientUrl(). Do not expose it as a parameter.

The function MUST use the OData $batch endpoint via HTTP POST. Do not use a direct GET request under any circumstances. The implementation must follow these rules exactly:

TRANSPORT:

POST to: {baseUrl}/api/data/v9.2/$batch
Outer POST headers:
Content-Type: multipart/mixed;boundary=batch_evaluate
Accept: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0
BATCH BODY FORMAT:

The multipart boundary identifier must be: batch_evaluate
The body must be a valid OData batch request containing a single inner GET request:
--batch_evaluate
Content-Type: application/http
Content-Transfer-Encoding: binary

GET {baseUrl}/api/data/v9.2/north52_formulacalculations?select=north52_result&filter={encodedFilter} HTTP/1.1
Accept: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0

--batch_evaluate--

FILTER CONSTRUCTION:

Escape single quotes in all four filter values by replacing each ' with ''
Build the parameters value as the string <${entity}></${entity}> before applying OData escaping, where entity is the third parameter used as the XML tag name
Build the $filter using all four fields joined with " and ":
north52_name eq '${escaped shortCode}'
north52_parameters eq '${escaped parameters}'
north52_targetentityid eq '${escaped targetEntityId}'
north52_formulatype eq '${escaped formulaType}'
Apply encodeURIComponent to the complete filter string before embedding it in the inner GET URL

RESPONSE PARSING:
1. The $batch response is multipart; extract the JSON payload.
2. Access the raw result via: const rawResult = json?.value?.[0]?.north52_result;
3. If rawResult is null, return null.
4. IMPORTANT: The rawResult is a JSON string (e.g., '{"PropertyValueAction":["Valid"]}'). 
   You MUST parse this string: const innerJson = JSON.parse(rawResult);
5. Return innerJson?.PropertyValueAction?.[0] ?? null.

Wrap the entire function in try/catch
If the outer POST response is not ok, log North52 batch request failed [status]: errorText to console.error and return null
If no result is found, return null
Log all caught exceptions to console.error and return null
Only output the function code. Do not include explanations, import statements, or surrounding boilerplate unless explicitly asked.

Pick up the primary key and entity name and pass them as parameters in the invocation from the current record.

Example invocations:
evaluateNorth52Formula("abc|", "{DA153A26-8EA1-420F-96AD-443DEFB3D7A1}", "account")
evaluateNorth52Formula("rty|", "{DA153A26-8EA1-420F-96AD-443DEFB3D7A1}", "contact")