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

Did you try checking the "Applies to Requested Items"?



If the client script method doesn't work, you can always try a display business rule using something like this:



      var gURL = new GlideURL();


      gURL.setFromCurrent();


      var ds = gURL.getParam("sysparm_description");


        current.description = ds;


Hi Chuck thanks for the quick response.  


Yes I did try 'Applies to Requested Items' but that didn't work.


although your business rule looks good - I'm completely awful when it comes to script in Service now.   What would the URL be?



You're probably sorry you answered me in the first instance now right



Eva


Wait, wait? I thought you were providing the URL.



I need more detail how you are turning this new call in to a request. That could be the source issue. I need to know what's being provided and then we can provide a way to do what's expected. I might be completely off base. Apologies, we seem to have strayed from the original question. Please restate as much information as you can around the new problem, or create a new discussion to get some fresh eyeballs on this.



Thanks Eva.


I know I'm confusing you now (I was confused a long time ago).



I guess the URL is :   'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=' + reqItem + '&sysparm_user=' + reqFor + '&sysparm_short_description=' + current.short_description + '&sysparm_description=' + current.description;




It's from the business rule that feeds the above catalog client script. To clarify the problem is that the formatting on the request item variable 'description' doesn't remain when it's passed from the description on the new_call into the variable.   The text is all bunch together and spacing and paragraphs are removed.




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(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;


}


To be honest, my mind is fried right now.



abhi_r any thoughts on this one?