Advanced script in PDF Template Mapping returns no value to the field

Niklas6
Tera Expert

I am using PDF Template and PDF Template mapping. I am using Advanced Script for the mapping and want to return something which is added to the field in the PDF document to be generated. 

 

If you use the Mapping Field field to map to the field in the case with the field in the template it works and the value in the field is added to the PDF document. If I use Advanced Script and just return some static text it doesn't work. Everything else is the same except changing to Advanced Script from direct mapping of fields. 

 

What can the problem be? Any idea is of value. I assume it cannot be cross scope problems since it works with direct mapping. Restricted Caller Access should create a record with status Requested if that was related I think (right?). There is no such record.

 

Niklas6_0-1684756239131.png

 

1 ACCEPTED SOLUTION

Niklas6
Tera Expert

The problem was that, of course, when it is advanced script the normal mapped field is not used. I need to get the script and execute it using GlideScopedEvaluator->evaluateScript().

View solution in original post

4 REPLIES 4

Amit Gujarathi
Giga Sage
Giga Sage

HI @Niklas6 ,
I trust you are doing great.

  1. Syntax or logic error in the Advanced Script: Double-check your script code for any syntax errors or logical issues that might prevent it from returning the expected result. Make sure the script is correctly implemented and returns the desired value.

  2. Script execution context: Confirm that the script has access to the required data and variables. Ensure that the script is executed within the appropriate context and has access to the field value you want to add to the PDF document.

  3. Script permissions and scope: Verify that the user executing the Advanced Script has the necessary permissions to access the field and perform the required actions. Check the script's execution scope and ensure it has the appropriate access rights.

  4. Debugging the script: Add logging statements or debug code within the Advanced Script to help identify any issues during execution. This can provide insights into the script's behavior and help pinpoint the problem.


Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



Thanks for the feedback! 

 

As you can see in my screenshot I am returning static text during the debugging just to avoid any other potential sources of error. I guess that would make 1, 2 and 4 not applicable. For 3 I run as admin so perhaps that is partly not applicable but scoping might be an issue? Not sure how to analyze 3 though, getting no errors in the error log and try catch isn't throwing anything either. 

Niklas6
Tera Expert

The problem was that, of course, when it is advanced script the normal mapped field is not used. I need to get the script and execute it using GlideScopedEvaluator->evaluateScript().

Can you clarify please? I have a need to pull in the filenames of all the files attached to the record and map it to a field on the PDF.  What do you mean the normal mapped field is not used?  And I'm not following how to execute  using GlideScopedEvaluator->evaluateScript()