Jump to content
Sign in to follow this  
smileee

Update attribute's value in cr via alg spell code

Recommended Posts

Hi everyone,

In cr table, I create new column "zbgt_summary check". I want to update the value of this attribute via using type of alg called SUM_CHECK. So I write a spell code on alg as the following quotes.

After I had used this type SUM_CHECK, the server not response. Other side, when I used  "send_wait(0, group_leader, "checkout", tech);" after "_action_desc = tech.zbgt_summary_check;" I got an error "update checkin of cr:404656 failed: AHD03025:Attempt to modify non_CO value".

Can anyone help me solve this issue?

Thanks in advance!

Quote

alg::zbgt_check_transfer(...)
{
    object group_leader,objGL,objRecord,act_log_table_record,zola_obj,zhitachi_line,cstName,m,zcr_obj,tech;
    string old_stt, cur_stt, where_clause, wc,att_grp_sla_wrk, zmsg,_type,_sub_action_desc,_description,_sub_description,_zresolution,_call_req_id,_cr,_zbgt_summary_check;
    uuid _analyst, cur_grp, old_asg, cur_asg;
    int zcr_count,zs_check,i,_action_desc;
    send_wait(0, top_object(), "get_co_group");
    group_leader = msg[0];
    send_wait(0, this, "get_attr_vals", 5, "type", "description", "zresolution","analyst","call_req_id");
    _type = msg[3];
    _description = msg[6];
    _sub_description = substr(_description, 0, 8);
    _zresolution = msg [9];
    _analyst = msg [12];
    _call_req_id = msg [15];

    logf(SIGNIFICANT, "_type = '%s'", _type);
    logf(SIGNIFICANT, "_description = '%s'", _description);
    logf(SIGNIFICANT, "_sub_description = '%s'", _sub_description);
    logf(SIGNIFICANT, "_call_req_id = '%s'", _call_req_id);
    
    if(_type=='TR' && (is_null(_description)|| _sub_description=='Transfer'))
    {
        zmsg="Yêu cầu điền lý do chuyển!";
        set_error(1);
        set_return_data(zmsg);
    }
    
    //Update  Summary Check value in cr
    wc = format("persistent_id = '%s'", _call_req_id); 
    send_wait(0, top_object(), "call_attr", "cr", "sync_fetch", "STATIC", wc, -1, 0);
    zcr_obj = msg[0];
    send_wait(0, zcr_obj, "dob_by_index", "DEFAULT", 0, 0);
    tech = msg[0];
    _action_desc = tech.zbgt_summary_check;
    tech.zbgt_summary_check = 400001;
    logf(SIGNIFICANT, "_action_desc = '%s'", _action_desc);
    send_wait(0, group_leader, "checkin");
}

 

Share this post


Link to post
Share on other sites

hi,

i think you can avoid spell in this scenario, you can simply define zbgt_summary_check on form level.

if you're creating activity (alg) using OP=UPDATE+FACTORY=cr (used in transfer, status change, escalate, etc) you can specify attr as:

docWriteln('<input name="SET.zbgt_summary_check" id="zbgt_summary_check" value="${args.zbgt_summary_check}">');

and if you're using OP=CREATE_NEW+FACTORY=alg like it used in log comment, code will be:

docWriteln('<input name="SET.call_req_id.zbgt_summary_check" id="zbgt_summary_check" value="${args.call_req_id.zbgt_summary_check}">');

js part:

function preSaveTrigger() {
	if (someErrorStatement) {
		alert("some error message");
		return false;
	} else {
		alert("DEBUG: Setting 400001 to zbgt_summary_check");
		jq("#zbgt_summary_check").val(400001);
		return true;
	}
}

preSaveTrigger triggers when user click Save button.

Regards, cdtj

Share this post


Link to post
Share on other sites

Thanks for your answer, cdtj.

But I still get stuck in putting your code in my form. I have Activity Type called "Summary Check" (code is SUM_CHECK) and the form of the "Summary Check" I write is resolved.htmpl . I can not put your code correctly in my form. Help me!

Quote

<PDM_IF 0>
request_status_change.htmpl
WHEN PRESENTED:
    when the app needs to update the status of a call request. When the user
    clicks the 'Close Request' button from the 'Update call request' screen.
INTENT:
    change the status of a call request.
VARIABLES:
    object cst    cst        A cst object (customer) that is the logged in user.
</PDM_IF>
<html lang="en"><head>
<PDM_PRAGMA RELEASE=110>
<PDM_INCLUDE FILE=styles.htmpl>
<script type="text/javascript">
<PDM_IF "$args.type" == "I">
    var form_title = "Summary Check Incident $args.ref_num";
<PDM_ELIF "$args.type" == "P">
    var form_title = "Status Change Problem $args.ref_num";
<PDM_ELSE>
    var form_title = "Status Change Request $args.ref_num";
</PDM_IF>
</script>
<PDM_INCLUDE FILE=std_head.htmpl>

<script type="text/javascript">
edit_form = 1;

var alg_factory = "alg";
var argPersistentID = "$args.persistent_id";
var argCstID = "$cst.id";
var argRefNum = "$args.ref_num";
var argID = "$args.id";
var _zHas_report_bgt="$args.zHas_report_bgt";
var def_code=alert_banner_fix_text("$args.KEEP.DEF_CODE");
var def_sym=alert_banner_fix_text("$args.KEEP.DEF_SYM");
var requestType = "$args.type";     // used in popup.js to demultiplex ticket types when searching for status values
<PDM_IF "<PDM_FMT ESC_STYLE=C PAD=NO>${AlertMsg:}</PDM_FMT>" != "">
    var user_set_status = "${args.user_set_status:}";
    var user_set_status_sym = "${args.user_set_status_sym:}";
</PDM_IF>
<PDM_IF $env.NX_KT == "Yes">
    <PDM_IF 0>
        When launching from a ticket, we want to know if the analyst has submitted a KD from ticket before, 
        so in case he has more knowledge to submit he could use the same KD
    </PDM_IF>
    var m_iNumberOfDocsSubmitted = 0;//Number of documents subbmitted from this document.
    var m_lSubbmitedDocumentID = "";
    <PDM_LIST FACTORY=kdlinks PREFIX=kdlinks WHERE="cr='$args.persistent_id' and link_type=3">
        m_iNumberOfDocsSubmitted ++;
        m_lSubbmitedDocumentID = "$kdlinks.kd";
    </PDM_LIST>
</PDM_IF>
</script>

<script type="text/javascript" src="$CAisd/scripts/arrow_button.js"></script>
<script type="text/javascript" src="$CAisd/scripts/check_submit.js"></script>
<script type="text/javascript" src="$CAisd/scripts/detail_form.js"></script>
<script type="text/javascript" src="$CAisd/scripts/val_type.js"></script>
<script type="text/javascript" src="$CAisd/scripts/kt_submit_kd.js"></script>
<script type="text/javascript" src="$CAisd/scripts/sitemods.js"></script>
<script type="text/javascript">
var resp_sym = new Array();
var resp_ids = new Array();
resp_sym[0] = "";
resp_ids[0] = "";
resp_field="SET.alg.description";
resp_persid='$args.persistent_id';

<PDM_IF "$args.type" == "R" || "$args.type" == ""> 
    <PDM_LIST ESC_STYLE=JS2 prefix=list factory=response where="delete_flag=0 AND (response_owner IS NULL or response_owner = U'$cst.id') AND cr_flag=1">
        resp_sym[resp_sym.length] = decodeURIComponent('$list.sym');
        resp_ids[resp_ids.length] = '$list.id';
    </PDM_LIST>
<PDM_ELIF "$args.type" == "I">
    <PDM_LIST ESC_STYLE=JS2 prefix=list factory=response where="delete_flag=0 AND (response_owner IS NULL or response_owner = U'$cst.id') AND in_flag=1">
        resp_sym[resp_sym.length] = decodeURIComponent('$list.sym');
        resp_ids[resp_ids.length] = '$list.id';
    </PDM_LIST>
<PDM_ELIF "$args.type" == "P">
    <PDM_LIST ESC_STYLE=JS2 prefix=list factory=response where="delete_flag=0 AND (response_owner IS NULL or response_owner = U'$cst.id') AND pr_flag=1">
        resp_sym[resp_sym.length] = decodeURIComponent('$list.sym');
        resp_ids[resp_ids.length] = '$list.id';
    </PDM_LIST>
</PDM_IF>
//To be called from the dtltextbox macro
function create_submit_knowledge_btn()
{
       docWriteln("<th>");
       <PDM_MACRO NAME=button caption="Submit Knowledge" hotkey_name="Submit Knowledge" id=btn004 func="submit_knowledge()">
       docWriteln("</th>");
}
function submit_knowledge()
{
    // If no KD was created from this ticket before, we'll just create a new KD
    // If 1 KD was created from this ticket before, we'll ask the user if he wants to review it or create a new one.
    // If more than 1 KDs were submitted from this ticket we'll ask the user if to create a new one and adivise him to look at the solutions tab
    var bCreateNewKD = true;//DEFAULT VALUE FOR m_iNumberOfDocsSubmitted = 0 case
    if(ahdtop.cfgNX_KT == "Yes")
    {
        if (m_iNumberOfDocsSubmitted == 1)
        {
            var sMsgText = msgtext("A_Knowledge_Document_was_already_submitted_from_this_request");
            <PDM_IF "$args.type" == "I">
                sMsgText = msgtext("A_Knowledge_Document_was_already_submitted_from_this_incident");
            <PDM_ELIF "$args.type" == "P">
                sMsgText = msgtext("A_Knowledge_Document_was_already_submitted_from_this_problem");
            </PDM_IF>
            if (confirm(sMsgText))
            {
                bCreateNewKD = true;
            }
            else 
            {
                var features="directories=no"+
                    ",location=no"+
                    ",height=" + popupHeight(LARGE_POPUP) +
                    ",width=" + popupWidth(LARGE_POPUP)+
                    ",status=no";
                //            
                bCreateNewKD = false;
                var lKDPersID = "KD:" + m_lSubbmitedDocumentID;
                popup_window(lKDPersID,'SHOW_DETAIL', 0, 0, features, 'PERSID='+lKDPersID,'+RELOAD_WIN=0');
                return;
            }
        }
        else if (m_iNumberOfDocsSubmitted > 1)
        {
            var sMsgText = msgtext("Several_Knowledge_Documents_have_been_submitted_from_this_request");
            <PDM_IF "$args.type" == "I">
                sMsgText = msgtext("Several_Knowledge_Documents_have_been_submitted_from_this_incident");
            <PDM_ELIF "$args.type" == "P">
                sMsgText = msgtext("Several_Knowledge_Documents_have_been_submitted_from_this_problem");
            </PDM_IF>
            if (!confirm(sMsgText))
            {
                bCreateNewKD = false;
            }    
        }
    }
    //
    if (!bCreateNewKD)
    {
        return;
    }
    var form_vars = new Array();
    //If the ticket detail page is opened and in edit mode, use the latest values to create the knowledge
    form_vars["SD_OBJECT_PERSID"] = "$args.persistent_id";
    if (null != top.opener && !top.opener.closed && typeof top.opener._dtl != "undefined" && top.opener._dtl.edit)
    {
        var func = top.opener.detailValueOf;
        form_vars["PROBLEM"] = func("SET.description"); 
        form_vars["SUMMARY"] = func("SET.summary");     
        form_vars["SD_ASSET_ID"] = func("SET.affected_resource"); 
        form_vars["SD_SEVERITY_ID"]= func("SET.severity");
        form_vars["SD_IMPACT_ID"] = func("SET.impact");
        form_vars["SD_URGENCY_ID"] = func("SET.urgency");
        form_vars["SD_PRIORITY_ID"] = func("SET.priority");
        form_vars["SD_CATEGORY"] = func("KEY.category"); 
        form_vars["SD_ROOTCAUSE_ID"] = func("SET.rootcause"); 
        <PDM_IF "$args.type" == "I">
            form_vars["SD_PROBLEM"] = func("SET.problem");
        <PDM_ELIF "$args.type" == "P">    
             form_vars["SD_PROBLEM"] = "$args.persistent_id";
         <PDM_ELSE>
             form_vars["SD_PROBLEM"] = "";
         </PDM_IF>        
    }
    else
    {
        form_vars["SUMMARY"] = <PDM_FMT ESC_STYLE=C>"$args.summary"</PDM_FMT>;
        form_vars["PROBLEM"] = <PDM_FMT ESC_STYLE=C>"$args.description"</PDM_FMT>;
        form_vars["SD_ASSET_ID"]="$args.affected_resource";
        form_vars["SD_SEVERITY_ID"]="$args.severity";
        form_vars["SD_IMPACT_ID"]="$args.impact";
        form_vars["SD_URGENCY_ID"]="$args.urgency";
        form_vars["SD_PRIORITY_ID"]="$args.priority";
        form_vars["SD_CATEGORY"]= <PDM_FMT ESC_STYLE=C>"$args.category.COMMON_NAME"</PDM_FMT>;
        form_vars["SD_ROOTCAUSE_ID"]="$args.rootcause";
        <PDM_IF "$args.type" == "I">
            form_vars["SD_PROBLEM"] = "$args.problem";
        <PDM_ELIF "$args.type" == "P">    
             form_vars["SD_PROBLEM"] = "$args.persistent_id";
         <PDM_ELSE>
             form_vars["SD_PROBLEM"] = "";
         </PDM_IF>
     }
     form_vars["RESOLUTION"] = detailValueOf("SET.alg.description");
     ahdtop.SetSolutionText(form_vars["RESOLUTION"],form_vars["SD_OBJECT_PERSID"]);
     ahdtop.SetProblemText(form_vars["PROBLEM"],form_vars["SD_OBJECT_PERSID"]);
<PDM_IF "$prop.form_name_3" == "ro">
        popup_window(
<PDM_ELSE>
        var oWin = window;
        if (!ahdtop.cstReducePopups && null != top.opener)
        {
            var oWin = top.opener;
        }
        oWin.popup_window(
</PDM_IF>  
        "", "CREATE_NEW", popupWidth(LARGE_POPUP), popupHeight(MEDIUM_POPUP), 
        "", "FACTORY=KD",
        addSubmitKnowledgePreSet(form_vars, "SD_OBJECT_PERSID", true),
        addSubmitKnowledgePreSet(form_vars, "SUMMARY", true),
        addSubmitKnowledgePreSet(form_vars, "SD_CATEGORY", true),
        addSubmitKnowledgePreSet(form_vars, "SD_ASSET_ID", true),
        addSubmitKnowledgePreSet(form_vars, "SD_ROOTCAUSE_ID", true),
        addSubmitKnowledgePreSet(form_vars, "SD_SEVERITY_ID", true),
        addSubmitKnowledgePreSet(form_vars, "SD_PRIORITY_ID", true),
        addSubmitKnowledgePreSet(form_vars, "SD_URGENCY_ID", true),
        addSubmitKnowledgePreSet(form_vars, "SD_IMPACT_ID", true),
        addSubmitKnowledgePreSet(form_vars, "SD_PROBLEM", true)
        );    
}

// The inc_valid_trans must be included AFTER detail_form.js in order to override that 
// files definition of backfill_event()
<PDM_IF "$args.type" == "R" || "$args.type" == ""> 
<PDM_INCLUDE file=inc_valid_trans.htmpl transStatus=$args.status transFactory=cr_trans>
<PDM_ELIF "$args.type" == "I">
<PDM_INCLUDE file=inc_valid_trans.htmpl transStatus=$args.status transFactory=in_trans>
<PDM_ELIF "$args.type" == "P">
<PDM_INCLUDE file=inc_valid_trans.htmpl transStatus=$args.status transFactory=pr_trans>
</PDM_IF>

</script>


</head>
<body onload="load_from_scratchpad('0');" onunload="unload_check()" class="editform">
<PDM_INCLUDE FILE=std_body.htmpl filename="" editForm=1>

<center>
<script type="text/javascript">
ahdframeset.top_splash.next_persid = "$args.persistent_id";
<PDM_MACRO name=dtlForm factory=cr>
<PDM_MACRO name=dtlStart>

docWriteln("<input type='hidden' name='HTMPL' value='show_main_detail.htmpl'>");
docWriteln("<input type='hidden' name='KEEP.IsModified' value='1'>");

if (_dtl && _dtl.next_persid == "")
    _dtl.next_persid = 'show_main_detail.htmpl';

<PDM_MACRO name=dtlStartRow>
<PDM_MACRO name=dtlReadonly hdr="$args.type.sym Summary" attr=summary colspan=2>
<PDM_MACRO name=dtlReadonly hdr="Current Status" attr=status>
<PDM_MACRO name=dtlStartRow>
<PDM_MACRO name=dtlTextbox hdr="Time Spent" attr=alg.time_spent evt="onBlur='validate_duration_ts(this)'" maxlength=100>
<PDM_MACRO name=dtlDate hdr="Date of Activity" attr=alg.time_stamp>
<PDM_MACRO name=dtlDateReadonly hdr="Time Stamp" attr=alg.system_time>
<PDM_IF "$prop.view_internal" == "1">
<PDM_MACRO name=dtlCheckbox hdr="Internal?" attr=alg.internal>
</PDM_IF>
<PDM_MACRO name=dtlStartRow>
<PDM_MACRO name=dtlLookup hdr="Main Technician" attr=zmain_tech evt="onBlur=\\\"detailSyncEditForms(this)\\\"" make_required="yes">
<PDM_MACRO name=dtlDropdown hdr="Summary Check" attr="zbgt_summary_check">
<PDM_MACRO name=dtlCheckbox hdr="Confirmation Document Type" attr="zHas_report_bgt" evt="onChange=\\\"make_desc_required_new(this.value)\\\"">
<PDM_MACRO name=dtlStartRow>
<PDM_MACRO name=dtlTextbox hdr="Cause of issue" attr=alg.description colspan=3 keeptags=yes rows=8 size=80 spellchk=yes>
<PDM_MACRO name=dtlStartRow>
<PDM_MACRO name=dtlTextbox hdr="Resolution" attr=alg.zresolution colspan=3 keeptags=yes rows=8 size=80 spellchk=yes>
make_desc_required();

if (resp_ids.length > 1)
{
<PDM_MACRO name=dtlStartRow>
}
    
if (typeof document.main_form.elements["KEY.status"] != "undefined")
{
    set_default_toggle(document.main_form.elements["KEY.status"]);

}
else{
    set_default_toggle(document.main_form.elements["SET.status"]);

}
function make_desc_required_new(value)

{

alert('value = ' + value);

        if ((value==1))

        {

            detailMakeReq("resolution_method",true);

        }

        else

        {

            detailMakeReq("resolution_method",false);

        };

    make_desc_required(value);

}

</script>
<PDM_MACRO name=dtlEnd>

</PDM_FORM>
</center>
<PDM_INCLUDE FILE=std_footer.htmpl>
</body>
</html>

 

Share this post


Link to post
Share on other sites

I checked my form again. This form is on cr. But when I insert your code into my form resolved.htmpl, I am not able to click the "Save" button.

Share this post


Link to post
Share on other sites

check browser console (hotkey F12) for errors

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×