Import a New Form using an API
- Last UpdatedNov 24, 2023
- 1 minute read
Use the following API to import a new Form :
try
{
// Specify the form Id
var formId = "C0084A77-0BAE-4237-9D75-1FA09B59E82B";
// Specify the form name
var formName = "New";
// specify the form version
var formVersion = "1";
// Specify the application/repository name
var applicationName = "PSI12Sprint05Repo";
// Forms List Name
var formListName = "Forms List";
BaseForm newDefinition;
BaseForm currentFormDefinition;
Skelta.Entity.UserContext userContext = new Skelta.Entity.UserContext(new Guid("B6FD1625-D203-4DEC-933D-516789E90E45"), new Skelta.Core.ApplicationObject(applicationName), "skeltalist");
Skelta.Forms.Web.CommonFunctions.ValidateCachedForm(formId, formVersion, out currentFormDefinition, formListName);
XmlDocument xmlDoc = new XmlDocument();
// Specify form definition xml file path
xmlDoc.Load(@"C:\PSI12Sprint05Repo_New_Form.xml");
var newFormDefinitionString = xmlDoc.InnerXml;
newDefinition = BaseForm.LoadDefinitionXml(newFormDefinitionString);
newDefinition = Workflow.NET.FormsUtility.UpdateNextGenFormDefinition(newDefinition);
newDefinition.TopLevelForm.FormTitle = formName;
Skelta.Forms.Web.CommonFunctions.UpdateDefinitionToDBAndValidateCache(formId, formVersion, newDefinition, formListName);
}
catch(Exception ex)
{
}
Note:
- The code imports the specified form definition without performing validations, for
example, checking product or build versions.
- If the the form definition contains an invoke workflow control, then the API imports
the form definition but does not create workflow association entries. You have to
create them manually.
- If a form definition contains an invoke workflow control, and if you import the
invoke workflow control from either the context menu or the Forms Designer, then the
workflow association entries are created.