Installing a Package on ACC with the InstallPackage xtkBuilder method | Community
Skip to main content
May 30, 2020
Solved

Installing a Package on ACC with the InstallPackage xtkBuilder method

  • May 30, 2020
  • 3 replies
  • 4392 views

I have a package I want to import using the method below that is described in the API docs

 

var params =
  {builder:
    {package:
      { ... }
    }
  }

NLWS.xtkBuilder.InstallPackage(params)

If i have a package that was generated (let's say package.xml). How exactly do i pass it into this function to install the package without errors?

Currently I can install the package through Tools -> Advanced -> Import Package and it works.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Jonathon_wodnicki

Hi,

 

The correct structure is:

<pkgDesc> <package buildNumber=".." buildVersion=".."> <entities/> </package> </pkgDesc>

 

Thanks,

-Jon

3 replies

Milan_Vucetic
Level 9
May 31, 2020

Hi @sarrankanp50398 ,

you may do it on this way:

  1. Convert XML package to JSON (open XML package with text editor, copy content and convert it to JSON via online converters)
  2. Add content to mentioned method and execute it in Java Script node.

Below is example how to import one dummy workflow package (consist of start and end node only) on my test environment.

var params = { "builder": {"package": {"entities": {"workflow": {"activities": {"start": {"transitions": {"initial": { "name": "initial","target": "end"}},"label": "Start","name": "start","x": "117","y": "2510"},"end": {"label": "End","name": "end","x": "257","y": "2509"}},"scenario": {"operation": "none","internalName": "notifySupervisor"},"desc": "Empty template to create a new workflow","folder": {"operation": "none","name": "sunFolder221"},"form": "xtk:workflow","internalName": "WKF4660","label": "test","modelName": "newWorkflow","scenario-cs": "Notification of the workflow supervisor (notifySupervisor)","schema": "nms:recipient"},"schema": "xtk:workflow"},"author": "Milan Vucetic (vucetic)","buildDate": "2020-05-31 17:22:54.563Z","buildNumber": "8981","buildVersion": "6.7"} } }
NLWS.xtkBuilder.InstallPackage(params);

 

Of course, you should explore options how to automate this.

 

Regards,

Milan

 

Jonathon_wodnicki
Community Advisor
Jonathon_wodnickiCommunity AdvisorAccepted solution
Community Advisor
June 1, 2020

Hi,

 

The correct structure is:

<pkgDesc> <package buildNumber=".." buildVersion=".."> <entities/> </package> </pkgDesc>

 

Thanks,

-Jon

Level 3
June 2, 2020

Hi @sarrankanp50398,

Steps:
1. Create a workflow
2. Save name of file(whole location) in a variable(like varFile)
3. In javascript activity, Read the file and save in a variable( you an use below code)

//read package file
var f = new File("varFile")
f.open("r", File.CODEPAGE_UTF8)
var readFile
var line
while( line = f.readln() )
readFile=readFile+line;
f.close()

 

var elementsToImport = <entities schema="xtk:srcSchema"/>;
elementsToImport.appendChild(readFile);
var wholePackage = <builder><package buildNumber="*">{elementsToImport}</package></builder>;
xtk.builder.InstallPackage(wholePackage);


Above code is just for reference, I haven't tested it, so you might need to make some changes.

Hope it will help.