Get Data By Business Key
Frontend
Setiap modul yang bersifat UserTask pada halaman create-nya terdapat fungsi
getByBusinessKey().const getByBusinessKey = async () => {
try {
setIsLoading(true);
const { data } = await axios.get(
`/api/${module}/${table}/get-by-business-key/${businessKey}`
);
const task = await BpmnService.getAvailableTask(businessKey!, { module, table });
if (task) {
setStatusTask(task.taskDefinitionKey);
setTitle(task.name);
}
setData(data.data);
} catch (error) {
console.error(error);
} finally {
setIsLoading(false);
}
};Business Key adalah sebuah ID model parent dari sebuah proses bisnis. Contoh pada proses bisnis parent model-nya adalah
KPM100, sehingga untuk mendapatkan detail modul child sepertiKPM130harus dariKPM100.Untuk mendapatkan task yang sedang berjalan bisa menggunakan.
const task = await BpmnService.getAvailableTask(businessKey!, { module, table });
Backend
Bagi service yang meng-extends class
SinergiUserTaskServiceWajib meng-override fungsi getByBusinessKey.public function getByBusinessKey(string $businessKey): ?Kpt130a
{
$service = new Kpt120Service(new Kpt120([]));
$kpt120 = $service->getByBusinessKey($businessKey);
$kpt130b = Kpt130b::where('kpt120a_id', $kpt120?->id)->whereNotNull('kpt120a_id')->first();
$kpt130a = Kpt130a::where('id', $kpt130b?->kpt130a_id)->with('vPenelaahan')->first();
return $kpt130a;
}Sehingga business key yaitu ID
KPM100bisa digunakan untuk mengambil detail dariKPM130.