Skip to content

Commit

Permalink
Product Feature - Done: Add finished version of UE script
Browse files Browse the repository at this point in the history
  • Loading branch information
MrRob committed Oct 24, 2024
1 parent f929e02 commit b73ada7
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* productFeatureUserEvent.ts
*
* @NScriptName Product Feature - User Event
* @NScriptType UserEventScript
* @NApiVersion 2.1
*/
define(["require", "exports", "N/log", "N/ui/message", "N/runtime", "N/translation"], function (require, exports, log, message, runtime, translation) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.beforeLoad = beforeLoad;
function beforeLoad(context) {
log.debug('beforeLoad', `${context.type} product feature record ${context.newRecord.id}`);
if (context.type == context.UserEventType.VIEW || context.type == context.UserEventType.EDIT) {
const bannerTitle = translation.get({ collection: 'custcollection_hitc_demo', key: 'record_out_of_date' })();
const bannerMessage = translation.get({ collection: 'custcollection_hitc_demo', key: 'please_update' })({ params: [runtime.getCurrentUser().name] });
context.form.addPageInitMessage({ type: message.Type.WARNING, title: bannerTitle, message: bannerMessage });
}
}
});
3 changes: 2 additions & 1 deletion src/TypeScripts/productFeatureUserEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
import {EntryPoints} from "N/types";
import log = require('N/log');
import message = require('N/ui/message');
import translation = require('N/translation');

export function beforeLoad(context: EntryPoints.UserEvent.beforeLoadContext) {
log.debug('beforeLoad', `${context.type} product feature record ${context.newRecord.id}`);
if (context.type == context.UserEventType.VIEW || context.type == context.UserEventType.EDIT) {
const bannerTitle = 'Record is out of date';
const bannerTitle = translation.get({ collection: 'custcollection_hitc_demo', key: 'record_out_of_date' });
const bannerMessage = 'Please update the content of this product feature description';
context.form.addPageInitMessage({ type: message.Type.WARNING, title: bannerTitle, message: bannerMessage });
}
Expand Down
22 changes: 22 additions & 0 deletions src/TypeScripts/productFeatureUserEvent_done.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* productFeatureUserEvent.ts
*
* @NScriptName Product Feature - User Event
* @NScriptType UserEventScript
* @NApiVersion 2.1
*/

import {EntryPoints} from "N/types";
import log = require('N/log');
import message = require('N/ui/message');
import runtime = require('N/runtime');
import translation = require('N/translation');

export function beforeLoad(context: EntryPoints.UserEvent.beforeLoadContext) {
log.debug('beforeLoad', `${context.type} product feature record ${context.newRecord.id}`);
if (context.type == context.UserEventType.VIEW || context.type == context.UserEventType.EDIT) {
const bannerTitle = translation.get({ collection: 'custcollection_hitc_demo', key: 'record_out_of_date' })();
const bannerMessage = translation.get({ collection: 'custcollection_hitc_demo', key: 'please_update' })({ params: [runtime.getCurrentUser().name] });
context.form.addPageInitMessage({ type: message.Type.WARNING, title: bannerTitle, message: bannerMessage });
}
}

0 comments on commit b73ada7

Please sign in to comment.