샘플 스크립트

  • 릴리스 버전: Australia
  • 업데이트 날짜 2026년 03월 12일
  • 소요 시간: 9분
  • 일반적으로 요청되는 샘플 스크립트를 선택하십시오.

    이 문서에서는 일반적으로 요청되는 몇 가지 샘플 스크립트를 보여줍니다. 더 많은 예시를 보려면 제안 사항과 함께 documentation@logik.io 에 메시지를 보내주십시오.

    샘플 번호 필드 결정:

    var count64 = 0;
    var count32 = 0;
    var perCoreProcessing = 40; //assuming 8 processors with 5 TFlops compute
    var cpu64Processing = 64*perCoreProcessing;
    var cpu32Processing = 32*perCoreProcessing;
    var cpu16Processing = 16*perCoreProcessing;
    var remainingCompute = cfg.estPeakOps;
    if(cfg.allowCPU64 == true) { //64 core allowed so divide by that
    	count64 = remainingCompute/cpu64Processing;
    	remainingCompute = remainingCompute%cpu64Processing;
    }
    if(cfg.allowCPU32 == true) {
    	count32 = remainingCompute/cpu32Processing;
    	remainingCompute = remainingCompute%cpu32Processing;
    }
    return count32;

    샘플 텍스트 필드 결정:

    var retStr = "";
    retStr = retStr + "64 vCPUs: " + Math.round(cfg.cpu64Count);
    retStr = retStr + "\\n32 vCPUs: " + Math.round(cfg.cpu32Count);
    retStr = retStr + "\\n16 vCPUs: " + Math.round(cfg.cpu16Count);
    retStr = retStr + "\\n8 vCPUs: " + Math.round(cfg.cpu8Count);
    retStr = retStr + "\\n1 vCPUs: " + Math.round(cfg.cpu1Count);
    return retStr;

    샘플 제품 규칙 스크립트:

    //Base Product
    var baseProductP2ID = "BP_ID";
    var inputs = {"g2BaseProduct": cfg.g2BaseProduct};
    var resultSet = lookup("SELECT Product2Id, ProductName FROM Dummytable WHERE ProductCode = :g2BaseProduct", inputs);
    for (var row of resultSet) {
    	ProductList.id = row.get("Product2Id");
    	ProductList.quantity = cfg.orderQty;
    	ProductList.bomType = "SALES";
    	ProductList.uom = "EA";
    	ProductList.level = 1;
    	ProductList.notes = row.get("ProductName");
    	ProductList.parentProduct = "01t5f000000uJgoAAE"; //parent product identifier. In this case top product being configured from SFDC
    	baseProductP2ID = row.get("Product2Id");
    	ProductList.uniqueIdentifier = baseProductP2ID; //Parent
    	...SF ProductID; not req'd if this has no other children
    	ProductList.next();
    	break;
    }

    for 루프가 있는 샘플 제품 규칙 스크립트:

    //var timesReplicate = cfg.numberOfComputeClusters; //this doesn't work yet.. If it does, we will replicate that many times easier
    var timesReplicate = [1,1,1,1,1,1,1,1,1,1]; //dummy 10 times loop based on 10x boolean true, Double loop for 100
    for (var parentStep of timesReplicate) {
    	for (var step of timesReplicate) {
    		if(cfg.cpu16Count > 0) {
    			ProductList.id = "01t5f000000v50CAAQ";
    			ProductList.quantity=Math.round(cfg.cpu16Count);
    			ProductList.notes="Provisioning " + Math.round(cfg.cpu16Count) + " number of 16 core vCPUs";
    			if(cfg.sendDirectlyToProvisioning == true) {
    				ProductList.bomType = "Manufacturing";
    				ProductList.level = 2;
    			} else {
    				ProductList.bomType = "SALES";
    			}
    			ProductList.next();
    		}
    		if(cfg.cpu8Count > 0) {
    			ProductList.id = "01t5f000000v50DAAQ";
    			ProductList.quantity=Math.round(cfg.cpu8Count);
    			ProductList.notes="Provisioning " + Math.round(cfg.cpu8Count) + " number of 8 core vCPUs";
    			if(cfg.sendDirectlyToProvisioning == true) {
    				ProductList.bomType = "Manufacturing";
    				ProductList.level = 2;
    			} else {
    				ProductList.bomType = "SALES";
    			}
    			ProductList.next();
    		}
    		if(cfg.cpu32Count > 0) {
    			ProductList.id = "01t5f000000v50BAAQ";
    			ProductList.quantity=Math.round(cfg.cpu32Count);
    			ProductList.notes="Provisioning " + Math.round(cfg.cpu32Count) + " number of 32 core vCPUs";
    			if(cfg.sendDirectlyToProvisioning == true) {
    				ProductList.bomType = "Manufacturing";
    				ProductList.level = 2;
    			} else {
    				ProductList.bomType = "SALES";
    			}
    			ProductList.next();
    		}
    		if(cfg.cpu64Count > 0) {
    			ProductList.id = "01t5f000000v50JAAQ";
    			ProductList.quantity=Math.round(cfg.cpu64Count);
    			ProductList.notes="Provisioning " + Math.round(cfg.cpu64Count) + " number of 64 core vCPUs";
    			if(cfg.sendDirectlyToProvisioning == true) {
    				ProductList.bomType = "Manufacturing";
    				ProductList.level = 2;
    			} else {
    				ProductList.bomType = "SALES";
    			}
    			ProductList.next();
    		}
    		if(cfg.cpu1Count > 0) {
    			ProductList.id = "01t5f000000v50SAAQ";
    			ProductList.quantity=Math.round(cfg.cpu1Count);
    			ProductList.notes="Provisioning " + Math.round(cfg.cpu1Count) + " number of 1 core vCPUs";
    			if(cfg.sendDirectlyToProvisioning == true) {
    				ProductList.bomType = "Manufacturing";
    				ProductList.level = 2;
    			} else {
    				ProductList.bomType = "SALES";
    			}
    			ProductList.next();
    		}
    	}
    }
    console.log("Added line items 100 times");
    return ProductList;

    샘플 배열 및 맵 함수:

    var productidArr = ["test123", "chtest123"];
    var inputs = {"productids": productidArr};
    var resultSet = lookup("SELECT uniqueidentifier, bomtype FROM bominformation WHERE productid IN (:productids)", inputs);
    
    var prodTypeMap = new Map();
    for (var row of resultSet) {
    	prodTypeMap.set(row.get("uniqueidentifier"), row.get("bomtype"));
    }
    var itemTypeManuf = productidArr.every((value) => {return prodTypeMap.get(value) != "Manufacturing";});
    if (isGood == false) {
    	return "Sales type item found";
    }
    var summary = "";
    productidArr.forEach((item, index) => {summary += index + " " + item + ". ";});
    return summary;

    의 SFDC에서 쌍둥이가 된 다중 선택 선택 목록 필드 CPQ 로 다중 선택 선택 목록 값을 끌어오는 방법 보강 구성/재구성 시:

    let x = (cfgRequest.yourTwinnedLogikField.value).split(";");
    cfgRequest.yourTwinnedLogikField.set("value", x);
    return cfgRequest;

    필드 값을 문자열로 연결하는 방법:

    stringVar = "";
    stringVar = stringVar.concat(cfg.varible1, cfg.variable2, cfg.variable3);
    return stringVar;// returns selected values of "variable1variable2variable3"

    CONTAINS 함수를 모방하는 방법:

    var yourVariable = "Field Value"; // Replace with your actual Field value
    if (yourVariable.includes("CU")) {
    	// Code you wish to execute when Field Value contains "CU"
    } else if (yourVariable.includes("AL")) {
    	// Code you wish to execute when Field Value contains "AL"
    } else {
    	// Code you wish to execute when Field Value doesn't contain "CU" or "AL"
    };