Changing custom table to OOB table

roomawakar
Tera Contributor

Hi All,

 

In the KB Article form, there is a related list called -"Configuration Items" which is related to a custom table(u_m2m_kb_ci).
I want to change this table relationship to the OOB table -'m2m_kb_ci' and also want to merge all the records from the custom table to the OOB table. Can we do so? If yes, then how? Can someone please suggest some solution.

 

Thanks,

Rooma

4 REPLIES 4

Uncle Rob
Kilo Patron

Assuming m2m_kb_ci has the exact same references as u_m2m_kb_ci, it should be possible.

I'm also assuming m2m_kb_ci is currently empty and we don't need to preserve old data or look for duplicates.
If you don't like code, you can build it in a simple Flow.

FLOW TO COPY DATA FROM OLD TABLE TO NEW TABLE
Trigger:  Scheduled
1) Look Up Records:  u_m2m_kb_ci
2) For Each of 1
3) Create Record:  m2m_kb_ci
--- cmdb_ci = (instance of 2).(whatever u_m2m_kb_ci's cmdb_ci reference is)

--- kb_knowledge = (instance of 2).(whatever u_m2m_kb_ci's kb_knowledge reference is)

To test this out on Dev you may want to limit the results from node 2 in the flow.  Check 10 or so at a time.

ALTERING INTERFACE TO USE NEW TABLE INSTEAD OF OLD
Configure your related list on the Knowledge Form.  Remove the old m2m related list, and add the newer OOB one.

FINAL CONSIDERATIONS
- Make sure you look for any business logic that made entries to u_m2m_kb_ci automatically
- Make sure you look for any reports that were based on the u_m2m_kb_ci table.

- Look for any notifications that were either triggered by or reference u_m2m_kb_ci

- Make sure you didn't lose function!  Why did you create u_m2m_kb_ci to begin with?  Does it have more (and essential) properties that m2m_kb_ci didn't have?

@Uncle Rob Thanks for your response. I will try it an let you know if this works. Also, can you please tell me where I can check the existing configuration of the related list?

I tried checking in the relationships under system definition and also in related list module, but I couldn't find it.

 

I thought of just updating the table from custom to OOB in the relationship instead of creating a new related list but couldn't find it.

You manage related lists from the form.  In the case of many-to-many tables, the form for the record on either side of the m2m.

@Uncle Rob I tried creating new related list through list layout and I was successful. Now, I am trying to copy the data from the custom table to OOB through Fix script.

But the script just added the blank row of same count as of custom table but the record was not copied.

 

Do I need to change anything in the script?

 

var gr = new GlideRecord('u_m2m_kb_ci');

gr.query();

while(gr.next()){

    var gr1 = new GlideRecord('m2m_kb_ci');{

    gr1.cmdb_ci=gr.cmdb_ci;

    gr1.kb_knowledge=gr.kb_knowledge;

    gr1.insert();

    }

}