I’ve tried to tweak previous similar solutions to fit my use case, but just can’t get it to work. I’m new to javascript and am probably making a silly mistake.
I am saving a parent object (Shipment) and child objects (ShippingRecords). Once I save, I want to redirect to the the shipment (the first row in the Shipment model). The snippet below is called from a button on a page title component where the model is Shipment.
I’ve included my entire snippet for reference, but the part I think I need help with is bolded below. I’m not sure if I’m doing the merge right, or if I need to put that piece of code elsewhere.
Thanks, as always, for the help.
var params = arguments 0], $ = skuid.$;
var models = skuid.model.map();
var ShipmentModel = models.Shipment;
var TheShipment = ShipmentModel.getFirstRow();
var shippingrecords = models.ShippingRecords;
ShipmentModel.save({callback:function(){
var Direction = TheShipment.Direction__c;
var Status = TheShipment.Status__c;
var ShipFrom = TheShipment.Ship_From__c;
var ShipTo = TheShipment.Ship_To__c;
var ShippingMethod = TheShipment.Shipping_Method__c;
var TrackingNumber = TheShipment.Tracking_Number__c;
var DateShipped = TheShipment.Date_Shipped__c;
var DateArrived = TheShipment.Date_Arrived__c;
$.each(shippingrecords.data,function(i,row){
shippingrecords.updateRow(row,{
Direction__c : Direction,
Status__c : Status,
Ship_From__c : ShipFrom,
Ship_To__c : ShipTo,
Shipping_Method__c : ShippingMethod,
Tracking_Number__c : TrackingNumber,
Date_Shipped__c : DateShipped,
Date_Arrived__c : DateArrived
});
});
shippingrecords.save();
var model = params.model;
var row = params.row;
var url = “/{{id}}”;
var merges = skuid.$(‘
’).append(model.mergeRow(row,url));
window.location=(merges.text());
}});