How to preserve/restore the sp_portal.icon value after a clone between instances?

laurelin
Mega Contributor

NOTE: I previously posted this in the "Now Platform" forum, I guess it was the wrong place.  Hopefully the developer community will have some useful input.

Background: we have different colored "themes" (I use the term loosely, not technically) in our various instances so that the developers are visually aware of which instance they are currently using.  In particular, the favicon is a different color in each instance.

Before we deployed a service_portal, it was easy to run our post-clone cleanup script to change the name of the glide.product.icon system property.  The favicon was referenced by name, hence our dev environment uses "dev-favicon.ico", our production environment uses "prd-favicon.ico", etc.

But now in the sp_portal table, the icon isn't a NAME, it's an actual file upload.  And whenever we clone from one instance to another, the icon in the target instance changes color to whatever-was-the-source instance, for all portal pages.  That's a serious problem here.

From my reading of the documents, it looks like using "Exclude Tables" and "Data Preservers" could be used, but this would prevent *ANY* change to the sp_portal table records.  That is: if we changed attribute login_page or knowledge_base (or just about any other attribute of the sp_portal record), we probably *would* want the changes to be copied into the target of the clone; the ONLY thing we do not want copied is the icon attribute; and from my reading, this is not how "Exclude Tables" and "Data Preservers" work.  Am I misunderstanding the docs?  UPDATE: from HI incident INT3678937, no I am not misreading the docs.  Data Preservers preserve an entire record, not individual fields in the record.

If it is not possible to preserve ONLY the icon attribute, then is it possible to do an automated upload to the icon field in our post-clone cleanup script?  How would I go about this?  I do have access to the MIDserver, and I could place the icon source images in well-known locations on the MIDserver.  But I do not know how I would go about duplicating the steps that I take when I click on the "Update" and "Choose File" and "OK" buttons of the interactive way to restore the icons.

Thanks in advance.

-- lauri

 
10 REPLIES 10

Jon Barnes
Kilo Sage

I think this method should work, but I don't have an environment I can test this on right now. This will preserve both the icon and logo files for the portal records:

Create 2 Clone Data Preserver records like this (pictured below, and attached to this reply as xml that you can import):

find_real_file.png

AND

find_real_file.png

laurelin
Mega Contributor

No, that doesn't help.  The icon field isn't a reference to sys_attachment, it is an image.  The icon is stored, bit-for-bit, right there in the sp_portal.icon field.

 

-- lauri

just to clarify, did you try my suggestion and it didn't work? I reviewed the data architecture of those tables, and it appears to me that the records are stored wholly in the sys_attachment table. and I performed a test to confirm it (this is in Kingston, and I doubt the data architecture has changed since they rolled out image fields, but I could be wrong).

The test is to find the sys_attachment record related to your sp_portal record in the sys_attachment table that is named "icon". export that to xml and change the table_sys_id value in the xml to the sys_id of a different portal (one that doesn't currently have an icon). then re-import that xml. By doing just that, it moved the icon from one portal to the other, which suggests that the icon is fully stored in the sys_attachment table, not in the sp_portal record itself.

I would be interested to see if the suggestion works, but I don't have multi environments I can test this on right now.

laurelin
Mega Contributor

Well, fortunately we have a clone from one subproduction instance to another that will be happening tonight, so I can actually try this.  We are helsinki, so the table structure may in fact be very different.  But I will try what you suggest and on Monday I should have the answer.

 

Thank you, lauri