【问题标题】:Attach files to record in Netsuite附加文件以在 Netsuite 中记录
【发布时间】:2022-06-27 19:44:11
【问题描述】:

我正在将附件从 Zoho 转移到 Netsuite。但是在将其附加到机会或任何其他对象时面临问题。我已经将文件上传到netsuite的文件柜中,并尝试将其与记录注释绑定。但这不起作用。它只是将注释添加到记录中,但文件选项中没有任何文件的迹象。

谢谢。 enter image description here

【问题讨论】:

    标签: file netsuite zoho


    【解决方案1】:

    您将使用record.attach 函数。您将需要文件和事务的内部 id。在 SS1(使用nlapiAttachRecord)中,首先列出文件参数很重要。 SS2 语法使这一点更清晰:

    record.attach({
        record:{
            type:'file',
            id:fileid
        },
        to:{
            type:'transaction', 
            id:transactionid
        }
    });
    

    【讨论】:

    • 感谢您的帮助。它奏效了,但这会在大众层面上奏效。我有大约 11,000 个附件需要随机会附上。
    • @HarjinderSingh 不知道是否有限制。如果您成功,机会页面的加载速度可能会很慢。你会如何看待有人利用它?只需压缩 11k 文件,让可能需要它们的人下载和浏览它们。或者将它们保存在 S3 上并提供链接或外部文件检查器
    【解决方案2】:
    /**
    * @NApiVersion 2.1
    * @NScriptType MapReduceScript
    * @NModuleScope SameAccount
    */
    
    /**
    * In this I am using Map Reduce script to process & attach multiple files from 
    * FileCabinet of NetSuite. So that it never goes out of governance.
    /
    define(['N/record','N/query'],
    (record,query) => {
      const getInputData = (getInputDataContext) => {
    
        try
        {
          /**
          * Query for getting transaction ID & other header detail of record.
          */
          let transQuery = "SELECT custrecord_rf_tid as tid, custrecord_rf_fid as fid, id FROM customrecord_rflink where custrecord_rf_comp <> 'T' and custrecord_rf_type = 11";
          let transQueryResult = runSuiteQuery(transQuery);
    
          if(transQueryResult.length > 0){
            log.debug("Count of record left to process--->", transQueryResult.length);
            return transQueryResult;
          }else{ //Incase where no transaction was left to transform.
            log.debug({title: "No Remaining Transaction!"});
            return 1;
          }
        }
        catch (e)
        {
          log.error({title: "Error inside getinput data.", details: [e.message,e.stack]});
        }
      }
    
     
      const map = (mapContext) => {
        try{
          let mapData = JSON.parse(mapContext.value);
          log.debug({title: "mapData after parse", details: mapData});
    
          let staginRecId = Number(mapData.id);
          let fileId = Number(mapData.fid);
          let billId = Number(mapData.tid);
    
          let outputVal = attachfile('file',fileId, 'inventoryadjustment', billId);
    
          let staginRec;
          if(outputVal === true){
            staginRec = record.submitFields({
              type: 'customrecord_rflink',
              id: staginRecId,
              values: {
                'custrecord_rf_comp': true
              }
            });
            log.debug("record saved with id-->", staginRecId);
          }else{
            log.debug("record saving failed with id-->", staginRecId);
          }
    
    
        }
        catch(e){
          log.error({title: "Error in Map", details: [e.message,e.stack]});
        }
      }   
    
      const reduce = (reduceContext) => {
    
      }
    
      const summarize = (summarizeContext) => {
        log.debug('Summarize completed');
      }
    
      function runSuiteQuery(queryString) {
        log.debug("Query", queryString);
        let resultSet = query.runSuiteQL({
          query: queryString
        });
        log.debug("Query wise Data", resultSet.asMappedResults());
        if(resultSet && resultSet.results && resultSet.results.length > 0) {
          return resultSet.asMappedResults();
        } else {
          return [];
        }
      }
      function attachfile(recType, recId, recTypeTo, recIdTo) {
        record.attach({
          record: {
            type: recType,
            id: recId
          },
          to: {
            type: recTypeTo,
            id: recIdTo
          }
        });
    
        return true;
      }
      return {getInputData,map,reduce,summarize};
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-06
      • 1970-01-01
      • 2021-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多