56033

Adding a new row to another table using java in Maximo

Question:

I have two tables that I'm working with: KINCIDENT and ASSISTANT. The main one is KINCIDENT and the two are linked using an ID. I'm able to add a new row from the application but I want to do this using Java. I tried the following code but did not work:

MboSetRemote assistSet = MXServer.getMXServer().getMboSet("ASSISTANT",userInfo); MboRemote newAssist = assistSet.add(); newAssist.setValue("LOCATION",x); newAssist.setValue("INCNUM",y); assistSet.save();

I checked to see if the row was added but it wasn't and I also didn't find any new entries in the database either. Am I missing something?

Answer1:

As long as your code is running, you should have seen that new record in the assistant table, but you definitely would not have seen that on the screen. To make the record appear on the screen, you have to know Maximo's "cache" system to get and edit the exact instance of the set that backs the screen, instead of just any instance (or a whole new instance like you created there).

I don't know where your Java code is (an app bean, an MBOSet, an MBO, or a field class) and I don't know what event/trigger you are hooking into (adding a new record, saving an existing record or something else), both of which are important to know. I will assume you are in an MBO class of the KINCIDENT object running in the "add()" method; meaning when a new KINCIDENT is created, you want to add a new ASSISTANT record. Running as part of that trigger should mean that you are already hooked into the screen instance of the KINCIDENT object when a user adds a new record. To make your ASSISTANT record appear in the set instance backing the screen, you need to the follow the screen's relationships from KINCIDENT to ASSISTANT. I'm assuming on the screen the ASSISTANT table is set up as a child of the KINCIDENT table using a relationship. In that case you just need to get the ASSISTANT set using that relationship. Assuming your relationship is named the same as the set ("ASSISTANT"), it would look something like this:

MboSetRemote assistSet = getMboSet("ASSISTANT"); MboRemote newAssist = assistSet.add(); newAssist.setValue("LOCATION",x); newAssist.setValue("INCNUM",y);

This will not save your record yet (persist it to the database), but you want to keep your saves to a minimum. Let the user specify if a record should be saved or not by them hitting the "save"/disk icon in the toolbar.

Recommend

  • Type specific constructor for generic class
  • Firebase OnSuccessListener is being called when it should fail
  • Example for subscribing for BLE indicate in android
  • simple way to map a json collection response into swift object class
  • How to use ResourceDictionary in Windows Phone class library project
  • How to validate a year I enter in textbox using jquery rule?
  • Regex for Specific Tag
  • WordPress > setting permalink option via script buggy?
  • Python PIL to extract number from image
  • Updating product post meta data in admin meta box field
  • Cannot save model when using ember render helper
  • How can I get the choice “H2” back in the H2 consol?
  • C#: Import/Export Settings into/from a File
  • How do I shift the decimal place in Python?
  • Zoom in and out of jPanel
  • Firefox Extension - Monitor refresh and change of tab
  • How can I set a binding to a Combox in a UserControl?
  • Saving Changes After In-App Purchase Has Been Purchased
  • AJAX Html Editor Extender upload image appearing blank
  • How to define and use opencv mat of user type
  • Django: Count of Group Elements
  • Deselecting radio buttons while keeping the View Model in synch
  • Nant, Vault & Windows Integrated Authentication
  • How to extract text from Word files using C#?
  • How to check if every primary key value is being referenced as foreign key in another table
  • Sending data from AppleScript to FileMaker records
  • Cassandra Data Model
  • In LanguageTool, how do you create a dictionary and use it for spell checking?
  • To display the title for the current loaction in map in iphone
  • Why joiner is not used after Sequence generator or Update statergy
  • Getting Messege Twice Using IMvxMessenger
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • File not found error Google Drive API
  • How can I remove ASP.NET Designer.cs files?
  • python draw pie shapes with colour filled
  • Is it possible to post an object from jquery to bottle.py?
  • Is there any way to bind data to data.frame by some index?
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • How can i traverse a binary tree from right to left in java?
  • Python/Django TangoWithDjango Models and Databases