Hi Alexey,
You can try creating a custom plugn.
First fetch the json value in a textarea on the form using 'set Form Data' Plugin.
Now the custom plugin would parse through this json and set the form fields.
consider json as : {"field_1dtstr":"test1","field_2dtstr":"teest2"}
//code starts here
// XML string as provided
string xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><?mso-infoPathSolution name=\"urn:schemas-microsoft-com:office:infopath:Form1:-myXSD\" href=\"manifest.xsf\" solutionVersion=\"1.0.0.4\" productVersion=\"14.0.0\" PIVersion=\"1.0.0.0\" ?><?mso-application progid=\"InfoPath.Document\" versionProgid=\"InfoPath.Document.2\"?><my:myFields xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xhtml=\"http://www.w3.org/1999/xhtml\" xmlns:pc=\"http://schemas.microsoft.com/office/infopath/2007/PartnerControls\" xmlns:d=\"http://schemas.microsoft.com/office/infopath/2003/ado/dataFields\" xmlns:dfs=\"http://schemas.microsoft.com/office/infopath/2003/dataFormSolution\" xmlns:my=\"http://schemas.microsoft.com/office/infopath/2003/myXSD\" xmlns:xd=\"http://schemas.microsoft.com/office/infopath/2003\"><my:field_1>test3</my:field_1><my:field_2>test4</my:field_2><my:field_3></my:field_3><my:field_4></my:field_4><my:field_5>{\"field_1dtstr\":\"test1\",\"field_2dtstr\":\"teest2\"}</my:field_5><xd:DataConnection Name=\"FR_FileInfo_DataFiles\" type=\"\"><dfs:myFields xmlns:my=\"http://schemas.microsoft.com/office/infopath/2003/myXSD/2025-02-24T18:53:57\" xmlns:d=\"http://schemas.microsoft.com/office/infopath/2003/ado/dataFields\" xmlns:dfs=\"http://schemas.microsoft.com/office/infopath/2003/dataFormSolution\" xmlns:xd=\"http://schemas.microsoft.com/office/infopath/2003\"><dfs:dataFields><d:FR_FileInfo_DataFiles FileID=\"\" FileInfo=\"\" FileName=\"\" IsLatest=\"\" PropPromotionValues=\"\" ReviewerId=\"\" RowVersion=\"\" RunDetails=\"\" SapConnectionName=\"\" SapSystemId=\"\" ScriptName=\"\" ScriptStoreId=\"\" ScriptVersion=\"\" SequenceGuid=\"\" /></dfs:dataFields><dfs:dataOrderByFields>\r\n\t\t\t\t{{OrderByFields}}\r\n\t\t\t</dfs:dataOrderByFields><xd:SchemaInfo LocalName=\"myFields\" NamespaceURI=\"http://schemas.microsoft.com/office/infopath/2003/dataFormSolution\"><xd:Namespaces><xd:Namespace LocalName=\"myFields\" NamespaceURI=\"http://schemas.microsoft.com/office/infopath/2003/dataFormSolution\" /></xd:Namespaces><xd:RequiredAnys /></xd:SchemaInfo></dfs:myFields></xd:DataConnection></my:myFields>";
// Parse XML
XDocument doc = XDocument.Parse(xmlString);
// Extract the JSON string from field_5
string field5Json = doc.Root.Element("my:field_5")?.Value;
// Parse the JSON using Newtonsoft.Json
JObject jsonObject = JObject.Parse(field5Json);
// Extract the field_1dtstr and field_2dtstr values
string field1dtstr = jsonObject["field_1dtstr"]?.ToString();
string field2dtstr = jsonObject["field_2dtstr"]?.ToString();
// Update field_3 and field_4 with these values
XElement field3 = doc.Root.Element("my:field_3");
XElement field4 = doc.Root.Element("my:field_4");
if (field3 != null) field3.Value = field1dtstr;
if (field4 != null) field4.Value = field2dtstr;
// code ends here
in above example i have used a static xml but this can be picked up from current document and run dynamically in custom plugin.
as you can see field_5 has the josn value (fetched from database) further i am parsing through this json and setting field_1dtstr to field_3 and field_2dtstr to field_4 on form respectively.
Documentation related to custom plugin : https://help.precisely.com/r/t/1016755365/2023-12-31/Automate-Evolve/pub/Latest/en-US/Automate-Evolve-User-Guide/Plug-ins?tocId=4himg_YrBfI~t16mtdrv2A§ion=plugins__add
Hope this helps.
Regards
------------------------------
Hammad Naeem
Precisely Software Inc.
------------------------------
Original Message:
Sent: 02-11-2025 09:22
From: Alexey Skotnikov
Subject: Json/XML transformation in workflow
Hello Experts!
We need to get several fields from SQL view as part of workflow, and doing that via Set Form Data plugin and $$GetValueFromDataConnection.
Unfortunately ,it executes same SQL query several times for each field, that is pretty slow, because the view is complicated.
Question: can we get data in json or xml format once and then parse it into several solution or form fields - or even reference it in workflow as an object?
------------------------------
Alexey Skotnikov
GPO, Data Governance
ABBOTT RAPID DX INTERNATIONAL LIMITED
------------------------------