Transfer case - Transferred case number is empty if system property 'glide.itil.assign.number.on.insert' is set to true


Description

If system property "glide.itil.assign.number.on.insert" is set to 'true', after transferring a case with existing case number, the original case will have an EMPTY number. This is happening since an in-memory record is used to get a new number for old case. The two case numbers (old and transferred) cannot be swapped directly since the number field could have unique constraint setup. Thus a new number is generated by creating an empty case record in-memory which is then used to update the old case. But when above property is set to true a new number is not generated until and unless the record is inserted. And the old case is updated with empty number field.

Steps to Reproduce

1. Set system property "glide.itil.assign.number.on.insert" to 'true':
/sys_properties.do?sys_id=ff129a57c61122b70102a01f535e71f1

2. Log out/in to for the change to take effect.

3. Open any HR Case and Transfer it with existing case number

Expected behaviour:
The original case should have been assigned a new number

Actual Behaviour:
The original case does not have any number

Workaround

Workaround 1:

- Revert the property to the OOB value 'false'.

 

Workaround 2:

- Updating the swapNumber function from hr_TransferCase will help achieve this.

- Currently a in-memory glide record is created to get new Number for the case being transferred.

- When we set system property "glide.itil.assign.number.on.insert" to 'true' a new number for in-memory glide record will not be generated without insert.

- So as a workaround we can check if this property is set and insert an empty case record to obtain the number.

- Once we have the number we can then go ahead and delete the newly created record since we don't need it anymore.

- Above number can be used to transfer the record.

Please refer the below code changes, this can be added in swapNumber function of hr_TransferCase script include before setNumber method is called- 

var newNumberForOldCase = "";
if(gs.getProperty("glide.itil.assign.number.on.insert") == "true"){
    record.insert();
    newNumberForOldCase = String(record.number);
    record.get(record.getUniqueValue());
    record.deleteRecord();
} else
    newNumberForOldCase = String(record.number);

Related Problem: PRB1498931