Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

VMI API handler

Describes the VMI handler.

AddVmiBinCollectionHandler – HandlerBase<AddVmiBinCollectionParameter, AddVmiBinCollectionResult>

OrderHandlerDescription
500ValidateContextChecks if EnableVMI is enabled and returns an error if not.
600GetVmiLocationSets the VmiLocation in the result if it finds the Location ID in the parameter or returns an error.
700GetProductsSets the ProductDtos in the result if it finds the products from the VmiBinDtos parameter or returns an error.
800AddVmiBinsValidates the MinimumQty, MaximumQty, and binNumber for duplicates and adds all products from the previous handler. If there is an error, it rolls back and returns an error code.
900CreateGetVmiBinResultsCalls the CreateGetVmiBinResult pipeline and fills the GetVmiBinResults object. Returns an error if anything fails.

AddVmiBinHandler – HandlerBase\<AddVmiBinParameter, AddVmiBinResult>

OrderHandlerDescription
400ValidateContextChecks if EnableVMI is enabled and returns an error if not.
500GetVmiLocationSets the VmiLocation in the result if it finds the Location ID in the parameter or returns an error.
600GetProductSets the ProductDto in the result if it finds the product or returns an error.
700AddVmiBinValidates the MinimumQty, MaximumQty, and binNumber, and checks for duplicates. If all checks pass, it adds the product. Any error returns an error code.
800AddVmiBinResultSets the GetVmiBinResult result using the CreateGetVmiBinResult pipeline. Returns an error if anything fails.

AddVmiCountCollectionHandler – HandlerBase\<AddVmiCountCollectionParameter, AddVmiCountCollectionResult>

OrderHandlerDescription
500ValidateContextChecks if EnableVMI is enabled and returns an error if not.
600GetVmiBinsSets the VmiBins result using the VmiBinId from the VmiCountModels parameter. Returns an error if something is missing.
700AddVmiCountsValidates the Count and VmiBinId and adds the VmiCounts to the result and database. Returns an error and rolls back any changes if something is not valid.
800UpdateVmiBinsLastAndPreviousCountsUpdates VmiBins using VmiCounts, including the following properties: PreviousCountQty, PreviousCountDate, PreviousCountUserName, LastCountQty, LastCountDate, and LastCountUserName.
900CreateGetVmiCountResultsPopulates GetVmiCountResults using the CreateGetVmiCountResult pipeline. Returns an error if something goes wrong.

AddVmiCountHandler – HandlerBase\<AddVmiCountParameter, AddVmiCountResult>

OrderHandlerDescription
500ValidateContextChecks if EnableVMI is enabled and returns an error if not.
600GetVmiBinSets the VmiBinresult using the VmiBinId parameter. Returns an error if something is missing.
700AddVmiCountValidates Count and adds the VmiCount to result and database. Returns an error if something is not valid.
800UpdateVmiBinsLastAndPreviousCountsUpdates the VmiBin using the VmiCount from the previous handler, including the following properties: PreviousCountQty, PreviousCountDate, PreviousCountUserName, LastCountQty, LastCountDate, and LastCountUserName.
900CreateGetVmiCountResultPopulates GetVmiCountResult using the CreateGetVmiCountResult pipeline. Returns an error if something goes wrong.

AddVmiLocationCollectionHandler – HandlerBase\<AddVmiLocationCollectionParameter, AddVmiLocationCollectionResult>

OrderHandlerDescription
500ValidateContextReturns an error if the AddVmiLocationCollection parameter is null. Otherwise, moves to the next handler.
600ValidateLocationsIf ValidationOnly, iterates over all AddVmiLocationCollection and checks for collisions. It fills Collisions and CollisionsDetected for the result.
700AddVmiLocationsIf not ValidationOnly, populates AddVmiLocationResultCollection result with all saved locations.

AddVmiLocationHandler – HandlerBase\<AddVmiLocationParameter, AddVmiLocationResult>

OrderHandlerDescription
400ValidateContextChecks if EnableVMI is enabled and returns an error if not.
500GetCustomerGets the ShipToId customer if set. Otherwise, sets the Customer result parameter if BillTo is found and the service call does not return an error. Returns an error if anything fails.
600AddVmiLocationChecks the Name and ensures it is not bigger than 255 characters. Returns error if invalid. If IsPrimaryLocation is set to true, marks all other locations as not primary. If there is a duplicate location, returns an error. Otherwise, saves it and sets VmiLocation result.
700CreateGetVmiLocationResultCalls CreateGetVmiLocationResult pipeline and sets GetVmiLocationResult result. Returns an error if it fails.

AddVmiNoteHandler – HandlerBase\<AddVmiNoteParameter, AddVmiNoteResult>

OrderHandlerDescription
500ValidateContextChecks if EnableVMI is enabled and returns an error if not.
600GetVmiBinSets the VmiBin result if found. Otherwise, returns an error.
700AddVmiNoteReturns an error if Note was not set. Otherwise, sets the VmiNote result with the saved VmiNote.
800CreateGetVmiNoteResultSets the GetVmiNoteResult result using the CreateGetVmiNoteResult pipeline. Returns an error if it fails.

GetVmiBinCollectionHandler – HandlerBase\<GetVmiBinCollectionParameter, GetVmiBinCollectionResult>

OrderHandlerDescription
400ValidateContextChecks if EnableVMI is enabled. Returns an error if not or skips the whole chain if NumberOfVisits <=0.
500GetVmiBinQuerySets the VmiBinQuery result and expands the product relation if ExpandProduct is true.
600ApplyFilteringFilters by IsActive, VmiBinIds, or VmiLocationId. If Filter is set, filters product using Elasticsearch. If not, checks for visible products using Elasticsearch. You can add extra filtering by one of these parameters: BinNumberFrom, BinNumberTo, PreviousCountFromDate, PreviousCountToDate, IsBelowMinimum, NumberOfTimesMinQtyReached or NumberOfPreviousOrders. NumberOfTimesMinQtyReached and NumberOfPreviousOrders are used only when NumberOfVisits is set. SearchCriteria parameter is used for exact match.
700ApplySortSorts result or BinNumber, if a parameter was not provided.
800ApplyPagingApplies pagination on VmiBinQuery.
900ExecuteQueryGets data from the database and puts it into the VmiBins result.
1000GetVmiLocationSets the VmiLocation result. If VmiBinIds has any value, gets location from VmiBins. Otherwise, uses the VmiLocationId parameter, or returns an error if it fails.
1100CreateGetVmiBinResultsFills GetVmiBinResults using CreateGetVmiBinResult. Returns an error if it fails.

GetVmiBinCountHandler – HandlerBase\<GetVmiBinCountParameter, GetVmiBinCountResult>

OrderHandlerDescription
500ValidateContextChecks if EnableVMI is enabled and returns an error if not.
600GetVmiBinQueryCreates the VmiBinQuery result parameter.
700GetCountFilters by IsActive and sets the Count result based on IsBelowMinimum or by using NumberOfVisits and one of two properties: NumberOfTimesMinQtyReached or NumberOfPreviousOrders.

GetVmiBinHandler – HandlerBase\<GetVmiBinParameter, GetVmiBinResult>

OrderHandlerDescription
400ValidateContextChecks if EnableVMI is enabled and returns an error if not.
500GetVmiBinGets the vmiBin using the VmiBinId parameter, or returns an error if it fails.

GetVmiCountCollectionHandler – HandlerBase\<GetVmiCountCollectionParameter, GetVmiCountCollectionResult>

OrderHandlerDescription
500ValidateContextChecks if EnableVMI is enabled and returns an error if not.
600GetVmiBinGets the vmiBin using the VmiBinId parameter, or returns an error if it fails.
700GetVmiCountQueryCreates the VmiBinQuery result parameter.
800ApplyFilteringFilters by the VmiBinId, GetUniqueByUser, Username, VmiCountId, PreviousCountFromDate, and PreviousCountToDate parameter properties.
900ApplySortSorts query. If the Sort parameter is not set, uses CreatedOn DESC and sets Sort result.
1000ApplyPagingApplies pagination.
1100ExecuteQuerySets VmiCounts result with executed query.
1200CreateGetVmiCountResultsUses the CreateGetVmiCountResult pipeline to fill the GetVmiCountResults result. Returns an error if anything fails.

GetVmiCountHandler – HandlerBase\<GetVmiCountParameter, GetVmiCountResult>

OrderHandlerDescription
500ValidateContextChecks if EnableVMI is enabled and returns an error if not.
600GetVmiCountSets the VmiCount result using the VmiBinId and VmiCountId parameter properties. Returns an error if it fails.

GetVmiLocationCollectionHandler – HandlerBase\<GetVmiLocationCollectionParameter, GetVmiLocationCollectionResult>

OrderHandlerDescription
400ValidateContextChecks if the UserProfileDto has a value and that EnableVmi is enabled. Returns an error if not.
500GetVmiLocationQueryCreates the VmiLocationQuery result. Expands customer if the GetCustomerLabel or GetCustomer parameter is true.
600ApplyFilteringFilters by available ShipTos, VmiLocationIds or LocationNames, if provided. Uses the Filter parameter to search by customer fields and the IsPrimaryLocation parameter to filter by IsPrimaryLocation.
650ApplyFilteringByUserSkips handler if UserId parameter is not set. Otherwise, applies filtering by user.
700ApplySortApplies Sort parameter. If not set, uses the Name as the default and sets the Sort result parameter.
800ApplyPagingApplies pagination.
900ExecuteQuerySets the VmiLocations result with executed database query.
1000CreateGetVmiLocationResultsUses the CreateGetVmiLocationResult pipeline to fill the GetVmiLocationResults result. Returns an error if anything fails.

GetVmiLocationHandler – HandlerBase\<GetVmiLocationParameter, GetVmiLocationResult>

OrderHandlerDescription
400ValidateContextChecks if EnableVMI is enabled and returns an error if not.
500GetVmiLocationGets the vmiLocation using the VmiLocationId parameter. Returns an error if it fails.

GetVmiNoteCollectionHandler – HandlerBase\<GetVmiNoteCollectionParameter, GetVmiNoteCollectionResult>

OrderHandlerDescription
500ValidateContextChecks if EnableVMI is enabled and returns an error if not.
550GetVmiLocationSkips the handler if there is a GetAllBinNotesForLocation parameter. Otherwise, sets the VmiLocation result using the VmiLocationId parameter. Returns an error if it fails.
600GetVmiBinSkips the handler if there is a GetAllBinNotesForLocation parameter. Otherwise, uses the VmiBinId parameter to get the vmiBin. Returns an error if it fails.
700GetVmiNoteQuerySets the VmiNoteQuery result query.
800ApplyFilteringIf there is a GetAllBinNotesForLocation parameter, filters by the VmiLocationIdparameter. Otherwise, filters by the VmiBinId parameter. When VmiNoteId parameter is provided, the user is, too.
900ApplySortSorts by CreatedOn descending.
1000ApplyPagingApplies pagination.
1100ExecuteQuerySets the VmiNotes result with executed database query.
1200CreateGetVmiNoteResultsUses the CreateGetVmiNoteResult pipeline to populate the GetVmiNoteResults result. Returns an error if it fails.

GetVmiNoteHandler – HandlerBase\<GetVmiNoteParameter, GetVmiNoteResult>

OrderHandlerDescription
500ValidateContextChecks if EnableVMI is enabled and returns an error if not.
600GetVmiNoteSets the VmiNote result using the service result, or returns an error.

RemoveVmiBinHandler – HandlerBase\<RemoveVmiBinParameter, RemoveVmiBinResult>

OrderHandlerDescription
500ValidateContextChecks if EnableVMI is enabled and returns an error if not.
600GetVmiBinSets the VmiBin result using the VmiBinId parameter. Otherwise, returns an error.
700RemoveVmiBinArchives the vmiBin from previous step.

RemoveVmiBinsHandler – HandlerBase\<BatchRemoveVmiBinParameter, BatchRemoveVmiBinResult>

OrderHandlerDescription
500ValidateContextChecks if EnableVMI is enabled and returns an error if not.
600GetVmiBinsSets the VmiBins results using the VmiBinIds parameter. Returns an error if VmiBinIds is empty or fails to populate the result.
700RemoveVmiBinsIterates over all VmiBins from the previous step and archives them.

RemoveVmiCountHandler– HandlerBase\<RemoveVmiCountParameter, RemoveVmiCountResult>

OrderHandlerDescription
500ValidateContextChecks if EnableVMI is enabled and returns an error if not.
600GetVmiBinSets the VmiBin result using the VmiBinId parameter. Returns an error if it fails.
700GetVmiCountSets the VmiCount result using the VmiCountId parameter. Returns an error if it fails.
800RemoveVmiCountRemoves VmiCount using result.
900UpdateVmiBinLastAndPreviousCountsRecalculates the next properties: PreviousCountQty, PreviousCountDate, PreviousCountUserName, LastCountQty, LastCountDate. and LastCountUserName.

RemoveVmiLocationHandler – HandlerBase\<RemoveVmiLocationParameter, RemoveVmiLocationResult>

OrderHandlerDescription
500ValidateContextChecks if EnableVMI is enabled and returns an error if not.
600GetVmiLocationSets the VmiLocation result using the VmiLocationId parameter. Returns it if there is an error.
700RemoveVmiLocationArchives the vmiLocation from previous step.

RemoveVmiLocationsHandler – HandlerBase\<BatchRemoveVmiLocationParameter, BatchRemoveVmiLocationResult>

OrderHandlerDescription
500ValidateContextChecks if EnableVMI is enabled and returns an error if not.
600GetVmiLocationsSets the VmiLocations result using the VmiLocationIds parameter. Returns it in case of error.
700RemoveVmiLocationsArchives the vmiLocations from previous step.

RemoveVmiNoteHandler – HandlerBase\<RemoveVmiNoteParameter, RemoveVmiNoteResult>

OrderHandlerDescription
500ValidateContextChecks if EnableVMI is enabled and returns an error if not.
600GetVmiBinSets the VmiBin result using the VmiBinId parameter. Returns it if there is an error.
700GetVmiNoteSets the VmiNote result using the VmiNoteId parameter. Returns an error if it fails.
800RemoveVmiNoteDeletes the vmiNote from previous step.

UpdateVmiBinHandler – HandlerBase\<UpdateVmiBinParameter, UpdateVmiBinResult>

OrderHandlerDescription
400ValidateContextChecks if EnableVMI is enabled and returns an error if not.
500GetVmiBinSets the VmiBin result using the VmiBinId parameter. Returns it if there is an error.
600GetProductSets the ProductDto result using the ProductId parameter. Returns an error if it fails.
700UpdateVmiBinValidates the MinimumQty and MaximumQty and updates the entity. Returns an error if it fails or gets duplicate records after updating.
800CreateGetVmiBinResultPopulates the GetVmiBinResult result using the CreateGetVmiBinResult. Returns an error if it fails.

UpdateVmiCountHandler – HandlerBase\<UpdateVmiCountParameter, UpdateVmiCountResult>

OrderHandlerDescription
500ValidateContextChecks if EnableVMI is enabled and returns an error if not.
600GetVmiBinSets the VmiBin result using the VmiBinId parameter. Returns it if there is an error.
700GetVmiCountSets the VmiCount result using the VmiCountId parameter. Returns an error if it fails.
800UpdateVmiCountUpdates VmiCount.Count. Returns an error if the value is negative.
900UpdateVmiBinLastAndPreviousCountsUpdates the next properties: PreviousCountQty, PreviousCountDate, PreviousCountUserName, LastCountQty, LastCountDate, and LastCountUserName.
1000CreateGetVmiCountResultPopulates the GetVmiCountResult result using the CreateGetVmiCountResult pipeline. Returns an error if it fails.

UpdateVmiLocationHandler – HandlerBase\<UpdateVmiLocationParameter, UpdateVmiLocationResult>

OrderHandlerDescription
400ValidateContextChecks if EnableVMI is enabled and returns an error if not.
500GetVmiLocationSets the VmiLocation result using the VmiLocationId parameter. Returns if if there is an error.
600UpdateVmiLocationChecks for duplicates after updating, and returns an error if found or if the length is bigger than 255 characters. If the IsPrimaryLocation parameter is true, marks all other locations as not primary. It also updates the Name, UseBins, IsPrimaryLocation, and Note properties.
700CreateGetVmiLocationResultSets the GetVmiLocationResult result using the CreateGetVmiLocationResult pipeline. Returns an error if it fails.

UpdateVmiNoteHandler – HandlerBase\<UpdateVmiNoteParameter, UpdateVmiNoteResult>

OrderHandlerDescription
500ValidateContextChecks if EnableVMI is enabled and returns an error if not.
600GetVmiBinSets the VmiBin result using the VmiBinId parameter. Returns it if there is an error.
700GetVmiNoteSets the VmiNote result using the VmiNoteId parameter. Returns an error if it fails.
800UpdateVmiNoteReturns an error if the Note parameter is blank. Otherwise, sets the Note and IncludeOnOrder properties.
900CreateGetVmiNoteResultSets the GetVmiNoteResult result using the CreateGetVmiNoteResult pipeline. Returns an error if it fails.