- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
昨日
いつもお世話になっております。
ポータル画面でレコードを開いた時、UIアクションを押下すると設定したテンプレートでレコード内容がPDF化される機能を実装したいと考えております。
しかし、以下のコードを設定してもうまくいきませんでした。
(function executeAction(current) {
// ドキュメントテンプレートの sys_id(事前に作成したテンプレート)
var templateSysId = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'; // ←テンプレートのsys_idを指定
// 出力するファイル名
var fileName = '契約書.pdf';
// APIインスタンス生成
var docGen = new sn_docGenerateDocumentAPI();
// ドキュメント生成(対象レコードに添付)
var result = docGen.generateDocumentForTask(current.sys_id, templateSysId, fileName);
// 結果確認
if (result) {
gs.info('ドキュメント生成成功: ' + fileName);
} else {
gs.error('ドキュメント生成に失敗しました');
}
})(current);
どのようにすればテンプレートでPDFが出力できるようになりますでしょうか。
解決済! 解決策の投稿を見る。
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
昨日
your code will work in UI action if it's server side and mapping etc is proper.
if you are planning to use Document templates then I assume your configuration is already there
check my blog on how to invoke that
Generating and Attaching Document Templates in ServiceNow to Record - Server Side
are you getting any cross scope errors in log?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
昨日
your code will work in UI action if it's server side and mapping etc is proper.
if you are planning to use Document templates then I assume your configuration is already there
check my blog on how to invoke that
Generating and Attaching Document Templates in ServiceNow to Record - Server Side
are you getting any cross scope errors in log?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
3 時間前
ブログに掲載いただいていた内容で実装ができました!!!!ありがとうございました!!!!!!
