The CreatorCon Call for Content is officially open! Get started here.

Web service Changes

MalikB
Tera Contributor

In ServiceNow, via WS, it should not be possible to assign an inactive group to a MEE or MEI deployment.

Affected operations:
1/ "createDeploiementMEE" operation
---------- affected field "u_coordinator_group"

2/ "updateMEE" operation
---------- affected fields: "u_coordinator_group" and "u_group_technical_coordinator"

3/ "createApprovalGroup" operation
---------- affected fields: "u_assignment_group"

4/ "createDeploiementMEI" operation
---------- affected fields: "u_coordinator_group", "u_group_technical_coordinator", and "u_assignment_group"

5/ "UpdateMEI" operation
---------- affected fields: "u_coordinator_group", "u_group_technical_coordinator", and "u_assignment_group"

Check: if the group is not active then:
- the WS must return a message indicating that the group is not active
- the update must not be effective. There are two scripts in two transform maps. I'll send them to you. I'll let you know when you can find a script solution.

 

        // 4. createDeploiementMEI
        if (source.u_coordinator_group != "" && !isGroupActive(source.u_coordinator_group)) {
            gs.log("Groupe coordinateur inactif", "ABO");
            ignore = true;
            error = true;
            source.error_msg = "Le groupe coordinateur (u_coordinator_group) est inactif.";
        }
        if (source.u_assignment_group != "" && !isGroupActive(source.u_assignment_group)) {
            ignore = true;
            error = true;
            source.error_msg = "Le groupe d'affectation (u_assignment_group) est inactif.";
        }
    }
    // 5. UpdateMEI
    if (source.u_type == "UpdateMEI") {
        if (source.u_coordinator_group != "" && !isGroupActive(source.u_coordinator_group)) {
            ignore = true;
            error = true;
            source.error_msg = "Le groupe coordinateur (u_coordinator_group) est inactif.";
        }
        if (source.u_group_technical_coordinator != "" && !isGroupActive(source.u_group_technical_coordinator)) {
            gs.log(source.u_group_technical_coordinator, "ABO");
            ignore = true;
            error = true;
            source.error_msg = "Le groupe coordinateur technique (u_group_technical_coordinator) est inactif.";
        }
        if (source.u_assignment_group != "" && !isGroupActive(source.u_assignment_group)) {
            ignore = true;
            error = true;
            source.error_msg = "Le groupe d'affectation (u_assignment_group) est inactif.";
        }
    }
  function isGroupActive(groupeSysId) {
        var grCoordinateurGroupe = new GlideRecord("sys_user_group");
        if (grCoordinateurGroupe.get("name", groupeSysId)) {
            return grCoordinateurGroupe.active;
        }
        return false;
    }

 

  // 1. createDeploiementMEE
    if (source.u_type == "createDeploiementMEE") {
        if (source.u_number != null && source.u_number != "") {
            ignore = true;
            error = true;
            source.error_msg = "Impossible de renseigner un numéro de ticket pour une création de ticket.";
        }
        var groupeCoordinateur = source.u_coordinator_group;
        if (groupeCoordinateur != "" && !isGroupActive(source.u_coordinator_group)) {
            ignore = true;
            error = true;
            source.error_msg = "Le groupe coordinateur (u_coordinator_group) est inactif";
        }
    }

    // 2. updateMEE
    if (source.u_type == "updateMEE") {
        if (source.u_coordinator_group != "" && !isGroupActive(source.u_coordinator_group)) {
            ignore = true;
            error = true;
            source.error_msg = "Le groupe coordinateur (u_coordinator_group) est inactif.";
        }
        if (source.u_group_technical_coordinator != "" && !isGroupActive(source.u_group_technical_coordinator)) {
            ignore = true;
            error = true;
            source.error_msg = "Le groupe coordinateur technique (u_group_technical_coordinator) est inactif.";
        }
    }

    // 3. createApprovalGroup
    if (source.u_type == "createApprovalGroup") {
        if (source.u_assignment_group != "" && !isGroupActive(source.u_assignment_group)) {
            ignore = true;
            error = true;
            source.error_msg = "Le groupe d'affectation (u_assignment_group) est inactif.";
        }
    }
   function isGroupActive(groupeSysId) {
        var grCoordinateurGroupe = new GlideRecord("sys_user_group");
        if (grCoordinateurGroupe.get("name", groupeSysId)) {
            return grCoordinateurGroupe.active;
        }
        return false;
    }
0 REPLIES 0