Model not loading all required data

Hi, we’ve witnessed a recurring issue with one of our Skuid pages not loading our Salesforce data completely. The issue seems to stem from accessing related fields on a Salesforce object e.g. accessing account information through a transaction custom object.

Case Scenario:
A user wants to create a supplier transaction for a segment (Flight, Bus, Train etc.). Once they create a segment they can go in the system and create a supplier transaction. The supplier(segment) transaction’s initial model’s rows are created on page load using an inline snippet. The values for these rows are mapped from the segments which need to be paid for.

Problem: Once the segment transaction model’s new rows are created, we are trying to access the Creditor__r.Paid_on_Statement__c field in a different snippet. However, some users are not being able to access that value.

Code:
Below is the inline snippet creating the rows for our segment transaction model. Here we are setting the Creditor(Account) of the segment transaction as the Creditor(Account) linked with the segment itself.

// Retrieve Segment model
var paymentSegmentsModel = skuid.model.getModel(‘PaymentSegments’);
var segments = paymentSegmentsModel.data;

// Retrieve Segment Transaction model
var paymentSegmentTransactionsModel = skuid.model.getModel(‘PaymentSegmentTransactions’);
paymentSegmentTransactionsModel.abandonAllRows();

// Map necessary Segment values to its Segment Transaction and create initial rows
$.each(segments, function(i, segment) {
var matchedCreditor = $.inArray(segment.Creditor__c, creditorIds);
// The reason not set as model condition is to get full list of creditors
// Not Credit Card Fee
var isNotCCFee = segment.RecordType.Name !== ‘Credit Card Fee’;
var isNotFlight = segment.RecordType.Name !== ‘Flight’;
var hasOutstandingAmount = segment.Amount_Outstanding_to_Supplier__c !== 0;
if (matchedCreditor > -1 && isNotCCFee === true && isNotFlight === true && hasOutstandingAmount === true) {
var additionalCondition = {
additionalConditions: [
{field: ‘Segment__c’, value: segment.Id},
{field: ‘Segment__r’, value: segment},
{field: ‘Creditor__c’, value: segment.Creditor__c},
{field: ‘Date__c’, value: paymentModelRow.Transaction_Date__c},
{field: ‘Transaction_Type__c’, value: paymentModelRow.Transaction_Type__c},
{field: ‘Transaction_Description__c’ , value: paymentModelRow.Payee_Text__c},
{field: ‘TicketNumberUI’, value: segment.Ticket_No__c},
],
doAppend: true
};
var row = paymentSegmentTransactionsModel.createRow(additionalCondition);
}

The above code is mapping correctly however when we try to access the Paid_on_Statement__c field using Creditor__r.Paid_on_Statement__c (see below), it’s not being retrieved/accessed.

Snippet where the Creditor__r.Paid_on_Statement__c is being used:

//Model generates actual segment transactions using the initial mappings created above
var segmentTransactionsModel = skuid.model.getModel(‘PaymentSegmentTransactions’);
var segmentTransactions = segmentTransactionsModel.data;
var segmentTransactionObjectList = ;
var additionalSegmentTransactionObjectList = ;
var hasPaidOnStatementCreditor = ‘NO’;
for(var i=0; i<segmentTransactions.length; i++) {
var segmentTx = segmentTransactions[i];
var segmentTxObject = {
Id: segmentTx.Id,
Credit_Amount__c: segmentTx.Credit_Amount__c,
Creditor__c: segmentTx.Creditor__c,
Date__c: payment.Transaction_Date__c,
Reference__c: payment.Reference_Number__c,
Parent_Transaction__c: segmentTx.Parent_Transaction__c,
RecordTypeId: segmentTx.RecordTypeId,
Segment__c: segmentTx.Segment__c,
Transaction_Description__c: segmentTx.Transaction_Description__c,
Transaction_Type__c: segmentTx.Transaction_Type__c,
Agency_CC_Label__c: payment.Agency_CC_Label__c,
Agency_CC_Is_Batched__c: payment.Agency_CC_Is_Batched__c,
Enett_Payment_Options__c: payment.Enett_Payment_Options__c
};
if (segmentTx.Creditor__r.Paid_on_Statement__c,) {
additionalSegmentTransactionObjectList.push(segmentTxObject);
hasPaidOnStatementCreditor = ‘YES’;
} else {
segmentTransactionObjectList.push(segmentTxObject);
}
}

The problem is the if condition which is evaluating to false because there is no Paid_on_Statement being set on the model.

Notes -

  1. Paid on Statement is added as a field on both PaymentSegments and PaymentSegmentTransactions model.

  2. The permissions are set correctly for the users being affected.

  3. A similar issue had occured on our old version 11 Skuid where another field ‘Company Token’ (Creditor__r.Company_Token__c) wasn’t being retrieved from the same model.

  4. We are now running on Skuid ver 16.1.7

Hey @zainabzaman , welcome to the community!

It sounds like sometimes the snippets are working as expected (you can access the Creditor__r.Paid_on_Statement__c field), and sometimes they’re not (you can’t access that field), right?

Here are some things it might be helpful to think about:

  1. Is the data in the model coming from Salesforce? Is there a reason you’re using JS to load the model instead of a normal model query?
  2. Is there a reason you can’t retrieve the Paid on Statement field in the first snippet?
  3. Have you tried testing a similar query in Visualforce (outside of Skuid) and seen if you get the same issue?