BPM Flowable script is correct or wrong if wrong please provide right

20 views Asked by At

dedup_check

{'success': True, 'message': 'Record retrieved successfully.', 'data': \[{'id': '46f2a5c3-7c24-4e9b-b4e4-23c81b68cffc', 'created_at': '2024-01-27T12:47:10.552243Z', 'updated_at': '2024-01-27T12:47:10.552281Z', 'applicationId': 'A00268', 'source': 'Walkin', 'job_board': None, 'job_board_application_id': None, 'entity_data': {}, 'salary_offered': None, 'created_by': 'Aditya', 'closure_date': None, 'closure_amount': None, 'tentative_closure_date': None, 'closure_status': 'Pending', 'joiningDate': None, 'job': '2da00fdb-1a69-426e-ba13-5977b54c5c6b', 'hiring_event': None, 'candidate': 'd0ac98e2-155c-44b7-b880-201ed769d235', 'sourcing_partner': None, 'stage': '15358cbf-c016-43a4-9cea-b25958d54a09', 'state': '77376bef-1093-4924-8547-41f6d78cf762', 'pricing': None, 'tenant': 'e42630fa-bac9-4758-befa-f63ecc101800', 'slot_details': None, 'job_id': 'J00071', 'job_role': 'Operation Support', 'candidate_mobile': '+628298642950', 'candidate_name': 'Nivedita Singh prity', 'candidate_state': 'Screening Unscreened', 'state_name': 'Unscreened', 'stage_name': 'Screening', 'sourcing_partner__name': 'Walkin', 'entity_master_model_id': 'e6516b93-d7e3-4408-8667-37a8ed15153b', 'entity_view_id': ''}\], 'count': 1}

This result I am getting from a http request in flowable script

if (JSON.parse(dedup_check).count > 0) {
    var applicationId = JSON.parse(dedup_check).data[0].applicationId;
    if (applicationId) {
        var stateName = JSON.parse(dedup_check).data[0].state_name;
        var createdDate = new Date(JSON.parse(dedup_check).data[0].created_at);

        if (stateName !== 'Rejected') {
            var currentDate = new Date();
            var timeDifference = currentDate - createdDate;
            var daysDifference = timeDifference / (1000 * 60 * 60 * 24);

            if (daysDifference < 90) {
                var BpmnError = Packages.org.flowable.engine.delegate.BpmnError;
                throw new BpmnError("you have already submitted an application for this job.");
            }
        }
    }
}

please provide correction for this

0

There are 0 answers