Skip to main content

Get Data By Business Key

Frontend

  1. 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);
    }
    };
  2. 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 seperti KPM130 harus dari KPM100.

  3. Untuk mendapatkan task yang sedang berjalan bisa menggunakan.

    const task = await BpmnService.getAvailableTask(businessKey!, { module, table });

Backend

  1. Bagi service yang meng-extends class SinergiUserTaskService Wajib 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;
    }
  2. Sehingga business key yaitu ID KPM100 bisa digunakan untuk mengambil detail dari KPM130.