Expand my Community achievements bar.

SOLVED

Installing a Package on ACC with the InstallPackage xtkBuilder method

Avatar

Level 1

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.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

 

The correct structure is:

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

 

Thanks,

-Jon

View solution in original post

3 Replies

Avatar

Community Advisor

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

 

Avatar

Correct answer by
Community Advisor

Hi,

 

The correct structure is:

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

 

Thanks,

-Jon

Avatar

Level 3

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.