Keep formatting of text when copied into a variable

evaoconnell
Giga Contributor

I have enabled the New Call feature in ServiceNow (Fuji) and have an inbound action that pulls emails into the system into a new call and then I choose if it's a request or an incident.  

If I chose request then it will be one catalog item called Quick Request.   I use the OOB (only a couple of changes) 'CallTypeChanged to Request' business rule to pull the information into the requested item but when info of the new_call description field comes into the requested item description (which is a variable) it loses it's formatting.   Is there any way to keep the formatting correct in the variable?

1 ACCEPTED SOLUTION

Screenshot from my Fuji system... It seems to be there. Not sure why you aren't seeing it. It might be time to call customer support.


find_real_file.png


View solution in original post

28 REPLIES 28

Is your target variable is of type string? Can you also provide a snapshot of your sample new call description.


Hi Abhinay



Yes it's currently string but I've tried as HTML also.   See attached screenshot of New_Call and of the Request Item after it's been submitted.   You can see the line spacing has been lost.



find_real_file.pngfind_real_file.png


Here   you go,



You just need to encode your URL and you are good to go. Make sure the target variable is of string type not html.



var reqFor = current.caller;


var location = current.caller.location;


var reqItem = current.request_item;


var comments = "NEW_CALL_REF:"+current.sys_id+" "+current.description;



getCart();




var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=' + reqItem + '&sysparm_user=' + reqFor + '&sysparm_short_description=' + current.short_description + '&sysparm_description=' + current.description;




action.setRedirectURL(encodeURI(url));




function getCart() {


    var cart = new GlideRecord('sc_cart');


    var userid = gs.getUserID();


    cart.addQuery('user', userid);


    cart.query();


    if (cart.next()) {


          // We already have a cart so override the requested for value and empty it


          cart.requested_for = reqFor;


          cart.special_instructions = comments;


          cart.delivery_address = getDeliveryAddress();


          cart.update();


          var cartItems = new GlideRecord('sc_cart_item');


          cartItems.addQuery('cart', cart.sys_id);


          cartItems.deleteMultiple();


    } else {


          cart.initialize();


          cart.user = userid;


          cart.requested_for = reqFor;


          cart.special_instructions = comments;


          cart.delivery_address = getDeliveryAddress();


          cart.insert();


    }


    return cart;


}




function getDeliveryAddress() {


    var gr = new GlideRecord('cmn_location');


    if (!gr.get(location))


          return '';




    var text = '';


    if (!gr.street.nil())


            text = gr.street + '\n';


    if (!gr.city.nil() && !gr.state.nil() && !gr.zip.nil())


            text += gr.city + ", " + gr.state + ", " + gr.zip;


    return text;


}


That's it, fantastic.



Thank you so much, I would never have got that.