How to Link text frames in Writer via macro?

Is is possible to Link two Text Frames to together python or basic?

I am trying to accomplish setting the Previous and Next Fields of a Text Frames in a macro.

A frame (com.sun.star.text.TextFrame) has properties ChainPrevName and ChainNextName but when I try to assign values it has no effect, even though the frames exist on the page. The properties report as empty strings.

On a Side note:
I found trying to set Name property via frame.setPropertyValue() in Python did not work (raises UnknownPropertyException), which is strange as I can set most any objects properties using setPropertyValue().

However, setattr(frame, "Name", "SomeName") works.

Hello,

strange…

This works here:
The document holds 2 frames, named "MyFrame1" and "MyFrame2".
The following code creates the forward link from MyFrame1 to MyFrame2, then suppresses it:

Dim lo_Doc As Object
Dim lo_Frames As Object
Dim lo_Frame1 As Object

lo_Doc = ThisComponent
lo_Frames = lo_Doc.TextFrames
lo_Frame1 = lo_Frames.getByName("MyFrame1")
lo_Frame1.chainNextName = "MyFrame2" 'adds the link
lo_Frame1.chainNextName = ""         'suppresses the link

LibreOffice 7.3.6 official under LinuxMint 20.2 cinnamon.

Is seems the isssue I thought I was having was not related to chainNextName failing.

I my test I was adding text, using my add_text_frame() method, to both frames and then trying to link them.

This is a no, no.
It Seemes Writer will not allow linking if both text frames have text.

Thanks for answer. Seeing that it was working for you got me to inspect what was going on much more closely.
Now all is working.