调用请求-无法填充位置(树选择器)

时间:2018-11-06 12:16:40

标签: request servicenow

我有一个业务规则,即通过URL字段属性传递。

我需要的所有字段都可以,但是我在位置上遇到了问题-它的变量通过URL传递,但是没有放入请求字段。 你能帮我吗? 有人遇到过同样的问题吗? 我该如何解决?

    var reqFor = current.caller;
var contactType = current.contact_type;
var location = current.caller.location;
var reqItem = current.request_item;
var comments = "NEW_CALL_REF:" + current.sys_id + " " + current.description;
var short_description = current.short_description;

getCart();

var url = "com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=" + reqItem 
    + "&sysparm_requested_for=" + GlideStringUtil.urlEncode(reqFor) 
    + "&sysparm_location=" + GlideStringUtil.urlEncode(location) 
    + "&sysparm_special_instructions=" + GlideStringUtil.urlEncode(comments)
    + "&sysparm_stack=" + current.getLink()
    + "&sysparm_contact_type=" + contactType;
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.contact_type = contactType;
        cart.short_description = short_description;
        cart.description = comments;
        cart.special_instructions = comments + location; //add location for testing
        cart.delivery_address = getDeliveryAddress();
        cart.location = current.caller.location; //29.10.2018 
        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.contact_type = contactType;
        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;
}

0 个答案:

没有答案