Update Shift Info On Shift Paste callout

This callout retains the published or unpublished shift status when it is copied and pasted in ASV Mass Edit mode.

  1. Navigate to Maintenance > System Administration > Scriptable Extensions > Extension Script.
  2. Click New.
  3. Specify this information:
    Script Name
    Specify a name for the script.
    Description
    Optional. Leave the field blank.
    Script Type
    Specify mvs-callout-updateshiftinfoonshiftpaste and press Enter on your keyboard to load the Whitelists information.
    Template
    The callout name Update Shift Info On Shift Paste is automatically filled in.
    Time Limit (seconds)
    The default value is 120.
    Memory Limit (kilobytes)
    The default value is 100.
    Script
    Copy and paste the groovy script:
    package com.workbrain2.ta.publ.api.v7_0_0
    
    import com.workbrain2.emvs.publ.api.LayeredShiftPublService
    import com.workbrain2.emvs.publ.api.MVSPublicServiceAccess
    import com.workbrain2.emvs.publ.api.ShiftSummaryPublService
    import com.workbrain2.emvs.publ.api.callout.UpdateShiftInfoOnPasteScriptable
    import com.workbrain2.emvs.publ.api.domain.LayeredShiftPubl
    import com.workbrain2.emvs.publ.api.domain.LayeredShiftPublBuilder
    import com.workbrain2.emvs.publ.api.domain.ShiftSummaryPublBuilder
    import com.workbrain2.emvs.publ.api.domain.UnassignedShiftSummaryPubl
    
    class ChangePublishStatus extends UpdateShiftInfoOnPasteScriptable {
        LayeredShiftPubl updateShiftInfo(LayeredShiftPubl sourceShift, LayeredShiftPubl targetShift) {
            ShiftSummaryPublService shiftSummaryPublService = MVSPublicServiceAccess.shiftSummaryPublService
            ShiftSummaryPublBuilder shiftSummaryPublBuilder = shiftSummaryPublService.getShiftSummaryBuilder()
            shiftSummaryPublBuilder.init(targetShift.shiftSummary)
            if(sourceShift.shiftSummary.status == UnassignedShiftSummaryPubl.Status.UNPUBLISHED) {
                shiftSummaryPublBuilder.setShiftSummaryStatus(UnassignedShiftSummaryPubl.Status.STATELESS)
            } else {
                shiftSummaryPublBuilder.setShiftSummaryStatus(sourceShift.shiftSummary.status)
            }
    
            LayeredShiftPublService layeredShiftPublService = MVSPublicServiceAccess.layeredShiftPublService
            LayeredShiftPublBuilder layeredShiftPublBuilder = layeredShiftPublService.getLayeredShiftBuilder()
            layeredShiftPublBuilder.setShiftSummary(shiftSummaryPublBuilder.build())
            layeredShiftPublBuilder.setShiftDetails(targetShift.layeredShiftDetail)
            layeredShiftPublBuilder.build()
        }
    }
  4. Click Save.
  5. Navigate to Maintenance > System Administration > Scriptable Extensions > Extension Script Callouts.
  6. Click the Edit option for the Update Shift Info On Shift Paste callout name.
  7. In Script Name, select the name you specified.
  8. Click Submit.