To add the type of the class in script include is necessary or it can be optional

zeeshanIdrees
Tera Contributor
var PersonalizedMarketingScriptInclude = Class.create();  
PersonalizedMarketingScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {  
  
    getCustomerPreferences: function() {  
        try {  
            var customerId = this.getValue('sysparm_customer_id');  
            var gr = new GlideRecord('u_customer_interactions');  
            gr.addQuery('u_customer_ref', customerId);  
            gr.query();  
  
            var preferences = [];  
            while (gr.next()) {  
                var preference = {  
                    productCategory: gr.u_product_category,  
                    interactionType: gr.u_interaction_type,  
                    customerName: gr.u_customer_ref.u_name,  
                    customerEmail: gr.u_customer_ref.u_email,  
                    customerPreferences: gr.u_customer_ref.u_product_preferences  
                };  
                preferences.push(preference);  
            }  
  
            return JSON.stringify({ preferences: preferences });  
        } catch (e) {  
            return JSON.stringify({ error: 'Error fetching customer preferences: ' + e.message });  
        }  
    }  
});  
1 REPLY 1

Kieran Anson
Kilo Patron

Hi,

It's not strictly necessary, but there are some platform features/validation that may attempt to access the value. For consistency, I would keep it in.