How to Delete Deployed Calculation Flow
Like in the UI, deployed calculation flows (CF) cannot be deleted by users. You can only create a new empty CF with the same name and the CF processor will delete both.
import net.pricefx.automation.MyClient import net.pricefx.automation.TypeCode import net.pricefx.automation.automations.CalculationFlowsAutomation import net.pricefx.automation.automations.GenericAutomation import net.pricefx.integration.api.client.builder.FilterCriteriaBuilder import net.pricefx.integration.api.client.model.CalculationFlow import net.pricefx.integration.api.client.model.FilterCriteria import staticnet.pricefx.integration.api.client.builder.CriteriaBuilder.equal; // TODO - you need to rewrite this code to use proper PriceFxClient - to link to your specific environment def clients = MyClient.getClients("QA", [ "companyname", ], false); // TODO - change CF name here def CF_Name_TO_BE_DELETED = "test" FilterCriteriacriteriaDeployed = newFilterCriteriaBuilder() .and() .with(equal("uniqueName", CF_Name_TO_BE_DELETED)) .with(equal("draft", false)) .create(); FilterCriteria criteriaDraft = newFilterCriteriaBuilder() .and() .with(equal("uniqueName", CF_Name_TO_BE_DELETED)) .with(equal("draft", true)) .create(); for (MyClient client : clients) { println(CF_Name_TO_BE_DELETED + "tobedeleted") def cfDraft = CalculationFlowsAutomation.fetchCalculationFlow(client, criteriaDraft) def cfDeployed = CalculationFlowsAutomation.fetchCalculationFlow(client, criteriaDeployed) if (cfDraft) { CalculationFlowsAutomation.deleteCalculationFlow(client, cfDraft) } if (cfDeployed) { cfDeployed.setFlowId(null) cfDeployed.setConfiguration(null) CalculationFlowsAutomation.addCalculationFlow(client, cfDeployed) } }
Found an issue in documentation? Write to us.