Notifications
Clear all

[Solved] Implementing Data Retrieval for Display and Update in PartnerDetail.js: Seeking Guidance

2 Posts
2 Users
2 Reactions
790 Views
1
Topic starter

I have written a JS patch for PartnerDetail.js and added an additional field from partner.mdf. Now, I can see the field, and when I enter a record and click on update, the database gets updated. However, I want to retrieve the record from the database and display it in a text field so the user can see the actual value before updating it. How can I achieve this? Do I need to write an AJAX call or a Java class to store the value in a JSON object, or something else? Is there any documentation or something regarding this. Any guidance or documentation on this would be greatly appreciated!

sending my patch code

 

// #Patch SCC/admin/PartnerDetail
define(["SCC/admin/PartnerDetail"], function() {
var originalBuildLayout = SCC.PartnerLayout.buildLayout;

SCC.PartnerLayout.buildLayout = function(modelFields) {
var layout = originalBuildLayout.call(this, modelFields);

var leftColumn = layout.items[0].items[0].items[0];

var boFHorizonField = modelFields.getField('BoFHorizon');
if (!boFHorizonField) {
leftColumn.add({
xtype: 'textfield',
name: 'BoFHorizon',
fieldLabel: Labels.get("meta.field.BoFHorizon"),
width: 185
});
}

return layout;
};
});

1 Answer
1

If the field is added to the view or action screen, the Model Form framework should load it automatically. I'm not sure if it's possible to do that or feasible to replace the action screen in this case, so one alternative is to manually include the data for the one field in the response using a server-side listener.

To create a server-side listener, you can follow the instructions on this page by creating and annotating a subclass of BaseModelResourceListener: https://docs.onenetwork.com/NeoHelp/devnet/Server-side_Customization.html

There are 2 variants of onActionScreenExecuted: 1 allows access to the Model instance, and 1 allows access to the full ModelFormJSONObject response before it's returned to the client. You could probably store a reference to the Model in the first callback method and use it to put the MDF value into the JSON in the second callback method. Here are the Javadocs: https://devnet.onenetwork.com/oms/apps/DeveloperNetwork/www/docs/api/javadoc/com/onenetwork/platform/integ/rest/model/BaseModelResourceListener.html

 

javamk Topic starter 2024-07-02 07:11:34

@sean-durkin Thank you very much for the approach and for sharing all the documentation links. I tried multiple ways, but nothing worked out. I appreciate your help and will try it 🙂