0

But now need not place weekends

if 'Plan Start' != null and 'Date Rev 0' != null then
    let dates := 'Date Rev 0' - 'Plan Start';
    let 'step' := dates / 4;
    'Date Rev Int' := 'Plan Start' + 'step';
    'Date Rev A' := 'Plan Start' + 'step' * 2;
    'Date Rev B' := 'Plan Start' + 'step' * 3
end

I have 5 field dates, I put the first and last and the other 3 calculate the script on (trigeerTrigger after update), but now need not place weekends.

1 reply

null
    • Fred
    • 3 days ago
    • Reported - view

    Try something like:

    if 'Plan Start' != null and 'Date Rev 0' != null then
        let dates := 'Date Rev 0' - 'Plan Start';
        let 'step' := dates / 4;
    'Date Rev Int' := switch weekday('Plan Start' + 'step') do
        case 5:
            'Plan Start' + 'step' + 2
        case 6:
            'Plan Start' + 'step' + 1
        default:
            'Plan Start' + 'step'
        end;
    'Date Rev A' := switch weekday('Plan Start' + 'step' * 2;) do
        case 5:
            'Plan Start' + 'step' * 2 + 2
        case 6:
            'Plan Start' + 'step' * 2 + 1
        default:
            'Plan Start' + 'step' * 2
        end;
    'Date Rev B' := switch weekday('Plan Start' + 'step' * 3) do
        case 5:
            'Plan Start' + 'step' * 3 + 2
        case 6:
            'Plan Start' + 'step' * 3 + 1
        default:
            'Plan Start' + 'step' * 3
        end;
    end

    If you want to test it out first you can put this in a formula field:

    if 'Plan Start' != null and 'Date Rev 0' != null then
        let dates := 'Date Rev 0' - 'Plan Start';
        let 'step' := dates / 4;
    let step1 := switch weekday('Plan Start' + 'step') do
        case 5:
            'Plan Start' + 'step' + 2
        case 6:
            'Plan Start' + 'step' + 1
        default:
            'Plan Start' + 'step'
        end;
    let step2 := switch weekday('Plan Start' + 'step' * 2;) do
        case 5:
            'Plan Start' + 'step' * 2 + 2
        case 6:
            'Plan Start' + 'step' * 2 + 1
        default:
            'Plan Start' + 'step' * 2
        end;
    let step3 := switch weekday('Plan Start' + 'step' * 3) do
        case 5:
            'Plan Start' + 'step' * 3 + 2
        case 6:
            'Plan Start' + 'step' * 3 + 1
        default:
            'Plan Start' + 'step' * 3
        end;
    end;
    step1 + ":" + weekday(step1) + " - " + step2 + ":" + weekday(step2) + " - " + step3 +
    ":" +
    weekday(step3)

    Then you can play around with the Plan Start and Date Rev 0 dates and see that none of the dates show a 5 or 6 after it. Remember that weekday() goes from 0 - 6 starting on Monday as 0 and Sunday as 6.

Content aside

  • Status Answered
  • 3 days agoLast active
  • 1Replies
  • 28Views
  • 2 Following