Automation and Triggers

Introduction

The opportunity, quote and booking processes in MediaVelox are perfectly intertwined and this is thanks to the several automations and triggers that are included in the package.

In addition to the "static" objects such as Publication with its Issues, Issue formats and Ad Position, the rather "dynamic" object Ad Position Placement - f42_dispo__AdPosCatalog__c - plays a central role.

f42_dispo__AdPosCatalog__c is related with a master-detail relationship with the following objects:

  • Booking - f42_dispo__DispoBook__c (Detail)

  • Blocked Positions -

    (Detail)

    • At the same time related with a detail relationship to Booking - f42_dispo__DispoBook__c.

The Salesforce Schema Builder provides a clear overview of these relationships:

The availability of an Ad Position Placement

The central field in the Ad Position Placement option is the formula field Availability- f42_dispo__countAvailable__c

API Field Name

Fomula

Formula Content

API Field Name

Fomula

Formula Content

f42_dispo__countAvailable__c

if( f42_dispo__Publication__r.f42_dispo__isDigital__c = TRUE,
(f42_dispo__physicalLimit__c - ( f42_dispo__blockedSumReserved__c + f42_dispo__blockedSumBooked__c + f42_dispo__DispoBookSumVolumeConfirmed__c + f42_dispo__DispoBookSumVolumeReserved__c )),
(f42_dispo__physicalLimit__c - ( f42_dispo__blockedCount__c + f42_dispo__blockedCountBooked__c + f42_dispo__confirmedCountRollup__c + f42_dispo__reservedCountRollup__c )))

Physical limit of an availability:

  • Minus blocked positions in reserved/posted status

  • Minus Booking entries with the status reserved/posted

The posted / reserved / blocked bookings are entered using rollup summaries for the Ad Position Placement object.

  • For digital publications, availability is recorded via the reserved/booked/blocked volume within a Booking / Blocked position entry.

  • For normal print publications, only the number of Booking / Blocked position entry.

How are Booking entries generated?

  • Reservations in MVX are made in the quotation process via the Product Property for the availability check.

  • The value of Product Property, in this case the Booking information, is written as a JSON String in the Specification Export field (SF42_QuoLI_Specification_Export__c) on the Position Object (sf42_quotefx__SF42_GenLineItem__c).
    → Here the IDs contain the corresponding availability, number of reservations, corresponding blocked positions.

  • When synchronizing the quote line items to the opportunity (creating opportunity products), the JSON string is written 1:1 to the opportunity line item in field sf42_quotefx__SF42_QuoLI_Specification_Export__c

When the quote Positions are synchronized with the opportunity, a trigger is used to create Booking entries in addition to the opportunity products in the AdSales area.


Booking Relevant Triggers

OpportunityLineItem.trigger

  • The central trigger for MVX

  • Responds to OpportunityLineItem creation from appero quote and creates new Booking entries for MediaVelox using the JSON specification sf42_quotefx__SF42_QuoLI_Specification_Export__c

  • If there are already Booking entries in the opportunity, these are not updated, but deleted and rewritten.

  • Creates new Blocked Position entries if the Booking triggers such a rule.

Dispobook.trigger

Temporal validity of Dispobook entries

If a Booking entry (f42_dispo__DispoBook__c) is no longer valid, the data record is set to "archived" using a checkbox. Archived bookings are no longer counted towards availability.

Also here a formula field is in the center:

API Field Name

Formula

Formula Content

API Field Name

Formula

Formula Content

f42_dispo__Calculated_Archive__c

if(
OR(TEXT(f42_dispo__Order_Processing__c) = 'canceled',
AND(
OR(
IF(RecordType.DeveloperName = 'Fixed Publication Date', f42_dispo__Issue__r.f42_dispo__ClosingDate__c < TODAY(),f42_dispo__Issue__r.f42_dispo__PublicationDateUntil__c < TODAY() ),
f42_dispo__Quote__r.sf42_quotefx__SF42_QuoValidThruDate__c < TODAY()
),
f42_dispo__Opportunity__r.IsClosed != true
)
),
true,false)

A Booking is set to archived if:

  • Booking canceled (status of the Booking entry)

  • The publication period is in the past:

    • For Print: f42_dispo__Issue__r.f42_dispo__ClosingDate__c

    • For Digital: f42_dispo__Issue__r.f42_dispo__PublicationDateUntil__c

  • Quote Valid Date is in the past and Opportunity is still open

Archived bookings are no longer counted against availability. However, since rollup summaries cannot be applied to calculation fields, the value of the field f42_dispo__Calculated_Archive__c is written with the help of a simple checkbox using a trigger:

This Dispobook.trigger is triggered by OpportunityLineItem.trigger

  • Writes the value of the field f42_dispo__Calculated_Archive__c into the checkbox field
    f42_dispo__archives__c.

  • Updates associated Blocked Position entries.

  • Updates the document dispatch belonging to a Booking (no voucher copy is created for cancelled Booking), for f42_dispo__MVX_ProofOfDeliveryRule__c, Record Type Based on Dispo Books.

Booking entries are not updated when their status or content changes, but are deleted and rewritten.
It is only during archiving that a Booking entry is not rewritten, but updated using the "archived" indicator.

DispoBlockedItems.trigger

Blocked Positions f42_dispo__DispoBlockedItems__c are also marked as archived using a calculation field:

API Field Name

Formula

Formula Content

API Field Name

Formula

Formula Content

f42_dispo__Calculated_Archive__c


at the Blocked Position

f42_dispo__DispoBookEntry__r.f42_dispo__Calculated_Archive__c



The field f42_dispo__Calculated_Archive__c in the Blocked Position uses a formula to transfer the value from the triggering Booking entry.

The DispoBlockedItems.trigger writes the value of the calculation field into the checkbox field f42_dispo__archive__c at the Blocked Position.

Opportunity.trigger

When the opportunity status changes, these changes also influence the Booking record. Here the Opportunity.trigger:

  • Writes new Booking and deletes existing ones when the opportunity is won and the booking status changes to confirmed.

  • The same proceed also for the corresponding Blocked Position

quote.trigger

As soon as a quote is rejected, the corresponding booking is set to archived (archive__c). The associated trigger is the quote.trigger.

quotelineitems.trigger

If a quotation with reservations is processed again and individual items in it are deleted, the corresponding Booking entry must be archived.

The quotelineitems.trigger checks whether a quote item is deleted and sets the corresponding Booking entry to archived (archive__c) before deletion.

Trigger für den Versand von Belegexemplaren

Issues.trigger

For Proof Of Delivery Rule (f42_dispo__MVX_ProofOfDeliveryRule__c) from the record type Based On Issues.

The Proofs of delivery, which arise from issue-based rules, are manually created using an Action from the Issue record page.
The button only sets an Issue status using checkbox f42_dispo__ProofOfDeliveriesCreated__c.

Only when the checkbox is checked will the issues.trigger run and therefore generate a Proof of Delivery record (f42_dispo__MVX_ProofOfDelivery__c).

ProofofDeliveryRules.trigger

Validation of the delivery address (when delivery address details are incomplete).

Proofsofdelivery.trigger

If issue-based Proof of Delivery records were created, the corresponding status is updated on the issue.