Skip to main content
9-Granite
December 22, 2025
Solved

CreoJS: Displaying Messages in Creo Message Log

  • December 22, 2025
  • 2 replies
  • 312 views

Hi All,

We are using Creo Parametric 11.0.5.0

As part of our migration from Creo Weblink to CreoJS, we are using the following Weblink code to display messages in the Creo Message Log:

 

Existing Weblink Code:

function printMsg(msg){
var texts = pfcCreate("stringseq");
texts.Append(msg + "\n");
try {
var glob = pfcCreate("MpfcSession");
glob.GetCurrentSessionWithCompatibility(2);
g_session = glob.GetCurrentSession();
g_session.UIDisplayMessage("usermsg.txt", "USER %0s", texts);
} catch (e) {}
}

In Creo Weblink, we used below code for pfcCreate but for CreoJS this is not needed:

function pfcCreate (className)
{
if (pfcIsWindows())
    return new ActiveXObject ("pfc."+className);
  else if (pfcIsChrome()) 
    return pfcCefCreate (className);
  else if (pfcIsMozilla())
  {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
    ret = Components.classes ["@ptc.com/pfc/" + className + ";1"].createInstance();
    return ret;
  }
}

 

Issue:

I am currently facing challenges with declaring stringseq in CreoJS because I didn’t create a pfcCreate previously for CreoJS. How can I declare stringseq in CreoJS now?

 

Can anyone provide guidance on how to achieve the same functionality with CreoJS?

Best answer by RandyJones

Weblink sequences have been changed to javascript arrays in CreoJS. See page 16 of this: 

https://www.ptc.com/support/-/media/support/refdocs/Creo_Parametric/12/creojsug_Creo12400.pdf?sc_lang=en

 

...

Convert Collections in Web.Link to Arrays in Creo.JS
Creo.JS changed Web.Link sequences representation to JavaScript arrays. This
enables use of JavaScript array construction and processing APIs.
The Web.Link functions that accept and return collections can be converted to use
arrays in Creo.JS.

...

2 replies

20-Turquoise
December 22, 2025

 

Can anyone provide guidance on how to achieve the same functionality with CreoJS?


I have found you can use this in CreoJS:

WebLink Code
var startOfWebLinkNotice = pfcCreate("stringseq");
startOfWebLinkNotice.Set(0, "Message Text here...");
session.UIDisplayMessage("messagesFile.txt", "Message Category", startOfWebLinkNotice);

CreoJS Code
let startOfWebLinkNotice = [];// replace stringseq with this
startOfWebLinkNotice.push("Message Text here...);
session.UIDisplayMessage("messagesFile.txt", "Message Category", startOfWebLinkNotice);
20-Turquoise
December 22, 2025

Weblink sequences have been changed to javascript arrays in CreoJS. See page 16 of this: 

https://www.ptc.com/support/-/media/support/refdocs/Creo_Parametric/12/creojsug_Creo12400.pdf?sc_lang=en

 

...

Convert Collections in Web.Link to Arrays in Creo.JS
Creo.JS changed Web.Link sequences representation to JavaScript arrays. This
enables use of JavaScript array construction and processing APIs.
The Web.Link functions that accept and return collections can be converted to use
arrays in Creo.JS.

...

9-Granite
December 22, 2025

Hi @RandyJones 
Thanks for the Quick Reply. 
I missed those portion in CreoJS user guide. Also in Page 18 they have give example for Array in CreoJS. Please see the below image

KS_13238586_0-1766422871628.png


Now the below code is working for me and i can be able to Display message in message log.

function printMsg(msg) {
const strTest=[];
strTest.push (msg);
try {
globalSession.UIDisplayMessage("usermsg.txt", "USER %0s", strTest);
} catch (e) {}
}