It's all about the answers!

Ask a question

Can not use JavaScript Library funcion in RPE template


Dmitry A. Lesin (24825996) | asked Aug 07 '18, 9:09 a.m.
edited Aug 07 '18, 9:11 a.m.
Hello!
Sorry, but I have a strange problem with JS library function. I'm doing everything like to:
But when I want use the function in a text element in the template, I'm getting a reference error:
Reference error in RPE
May be somebody knows why it happens. Help me please if possible!
Thank you!

Accepted answer


permanent link
Subramanya Prasad Pilar (4.6k16) | answered Aug 07 '18, 2:05 p.m.
edited Aug 07 '18, 11:20 p.m.

This is a design limitation in RPE. A library script cannot use variables or data properties. If so, RPE will not use the script as library.

You should see the following message logged in console:
CRRPE3615E The script with id xx has data or variable references and cannot be used as a library.

Though you could use the library script function within try catch block, it is as good as calling a function that is not defined and hence it will be caught.

Dmitry A. Lesin selected this answer as the correct answer

Comments
Kumaraswamy Gowda commented Aug 08 '18, 12:12 a.m.

Yes Prasad, it is the limitation.

>>> I ran a quick test. Though I could use the library script function within try catch block, the output does not contain what is expected from the function.
Are the data properties evaluated correctly during document generation? or is just during the "Test script"?


Dmitry A. Lesin commented Aug 10 '18, 8:14 a.m.

Yes, thanks

I checked the same, and it's correct. And even, try...catch block isn't required if any variables are excuded because there's no error.

2 other answers



permanent link
Kumaraswamy Gowda (39115) | answered Aug 07 '18, 10:36 a.m.

Did you check the "library script" property?



Thanks,
Kumar


Comments
Dmitry A. Lesin commented Aug 07 '18, 10:40 a.m.

 Yes, exactly!

Checked library setting

And I can find and insert this function in another element by CTRL-SPACE.


Dmitry A. Lesin commented Aug 07 '18, 10:41 a.m.

 I'm working with RPE v6.0.5!


Dmitry A. Lesin commented Aug 07 '18, 12:31 p.m.
But I found that it catches an error that  "displayAllTCNames" is not defined when I try to use it. It's strange, may be there's a bug in RPE because I can not use it in the same template, isn't there?
Thank you

permanent link
Kumaraswamy Gowda (39115) | answered Aug 07 '18, 10:47 a.m.

Could you try this in the text element?

try{
    displayAllTCNames()
}
catch(e){
    //catch and just suppress error
}


Comments
Dmitry A. Lesin commented Aug 07 '18, 10:49 a.m.

Cool! You are genius.

Thank you very much!

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.