1

インライン エディターのサブリストの一種であるサブリストに [すべてマーク]/[すべてマーク解除] ボタンを追加しようとしています。以下に、インラインエディターのサブリストでは機能しないリストタイプのサブリストのコードを追加しました。誰でもこれを見つけるのを助けることができますか?

function button1Func(type) {
if (type=='edit' || 'view')
    {
        var record =  nlapiLoadRecord(nlapiGetRecordType(), nlapiGetRecordId());
        var intCount = record.getLineItemCount('item');
        var headrow = document.getElementById("item_headerrow");
        var head = headrow.insertCell(0);
        head.innerHTML ="Select";
        for (var rep = 1; rep <= intCount; rep++)
            {
                var row = document.getElementById("item_row_"+rep);
                var x = row.insertCell(0);
                var newCheckbox = document.createElement("INPUT");
                newCheckbox.setAttribute("type", "checkbox");
                newCheckbox.setAttribute("id", "select_CheckBox"+rep);
                x.appendChild(newCheckbox);
            }
    }
 }

function button2Func(type) {
if (type=='edit' || 'view')
    {
        var record =  nlapiLoadRecord(nlapiGetRecordType(), nlapiGetRecordId());
        var intCount = record.getLineItemCount('item');
        for (var rep = 1; rep <= intCount; rep++)
            {
                var repId = record.getLineItemValue('item', 'item', rep);
                if(document.getElementById("select_CheckBox"+rep).checked==true){
                    makecopyfun(repId);
                }
                else
                {
                    continue;
                }
            }
        alert("Success");
    }
}

 function makecopyfun(repId){
   var record =  nlapiLoadRecord(nlapiGetRecordType(), nlapiGetRecordId());
  var intCount = record.getLineItemCount('item');
  record.insertLineItem('item',intCount + 1);
  alert (intCount);
  record.setCurrentLineItemValue('item','item',repId);
  record.commitLineItem('item');
  var id = nlapiSubmitRecord(record, true);
 }
4

3 に答える 3

1

まず以下のコードを書いてuserEventスクリプトを作成し、beforeLoadイベントに関数名(initnoload)を適用します。次に、そのスクリプトを見積もりにデプロイします。

function initonload(type, form, request) {
if (type=='edit' || type=='view') {

    var list = form.getSubList("item");
    list.addButton('custpage_markmark','Mark all','markall();');  //markall(); is function name from the client script
    list.addButton('custpage_unmarkmark','Unmark all','unmarkall();'); //unmarkall(); is function name from client script
    form.setScript('customscript_mark_all_item_quote'); // 'customscript_mark_all_item_quote' is the ID of script

 }
}

上記のコードは 2 つのボタンをサブリストに追加し、それらのアクションは定義済みの ScriptId を持つクライアント スクリプトで実行されます。

次のコードを記述し、クライアント スクリプトを作成します (注: クライアント スクリプトを保存するだけです。イベント関数名を指定せず、デプロイしないでください)。

function markall() {

    var count=nlapiGetLineItemCount('item'); //gets the count of lines
    for(var i=1;i<=count;i++) {
        nlapiSelectLineItem('item',i);
        nlapiSetCurrentLineItemValue('item','custcol_checkbox_field','T',true,true); //'custcol_checkbox_field' is checkbox's field ID.
    }
    nlapiCommitLineItem('item');
}
function unmarkall() {

    var count=nlapiGetLineItemCount('item');
    for(var i=1;i<=count;i++) {
        nlapiSelectLineItem('item',i);
        nlapiSetCurrentLineItemValue('item','custcol_checkbox_field','F',true,true); //'custcol_checkbox_field' is checkbox's field ID.
    }
    nlapiCommitLineItem('item');
}

クライアント スクリプトを保存したら、その ID をユーザー イベントの form.setScript('クライアント スクリプト ID') に貼り付けてください。関数

これがあなたを助けることを願っています。

何か困難に直面している場合はお知らせください。

ありがとうございました。

于 2016-09-21T16:09:23.657 に答える
1

レコード オブジェクトがないため、API ではわかりません。jQuery を使用してみてください。

于 2016-09-19T04:02:30.303 に答える