binxie
2024-01-22 4688e276eee13cd2e521aa55afb5725cb0fda270
force-app/main/default/pages/RentalApplyQR.page
@@ -23,7 +23,7 @@
                record = sforce.connection.query("select Id from ContentDocument where Id in (" + idList + ") and Title = \'QRCode-{!Rental_Apply__c.Name}\'");
            }           
             // 既にあれば無視
             console.log("record.size--------888------------",record.size);
             console.log("record.size--------888------------",record.size+'~'+record.getArray("records"));
            if (record.size == 0) {
                console.log("record.size--------777------------",record.size);
                var version = new sforce.SObject("ContentVersion");
@@ -53,27 +53,21 @@
                result = sforce.connection.update([es]);
                // window.location = '/' + '{!Rental_Apply__c.Id}';
            //申请书更新失败的话再次更新
            } else if ("{!Rental_Apply__c.QRId__c}" == '' || "{!Rental_Apply__c.QRId__c}" == null) {
                console.log("record.size--------666------------",record.size);
                // var records = record.getArray("records");
                // var es = new sforce.SObject("Rental_Apply__c");
                // es.Id = "{!Rental_Apply__c.Id}";
                // es.QRId__c = records[0].Id;
                // result = sforce.connection.update([es]);
                // TODO Name変わる可能性あり、upsertにします
            } else {
                // 20240113 ljh update start
                var records = record.getArray("records");
                console.log('zheliupdate:'+records[0].Id);
                var version = new sforce.SObject("ContentVersion");
                version = sforce.connection.query("select Id,ContentDocumentId from ContentVersion where ContentDocumentId = \'" + records[0].id + "\'");
                version = sforce.connection.query("select Id,ContentDocumentId from ContentVersion where ContentDocumentId = \'" + records[0].Id + "\'");
                version = version.getArray("records"); 
                if(version[0].id != "{!Rental_Apply__c.QRId__c}"){
                // 存在qr时,绑到清单上
                if(version[0].Id != "{!Rental_Apply__c.QRId__c}"){
                    var es = new sforce.SObject("Rental_Apply__c");
                    es.Id = "{!Rental_Apply__c.Id}";
                    es.QRId__c = version[0].id;
                    es.QRId__c = version[0].Id;
                    result = sforce.connection.update([es]);
                }
            } else {
                // alert(record[0].Id);
                // 20240113 ljh update end
            }
            // //20231027 ymh添加注释  lighting修改附件上传 end
        }