A solution not for InDesign Server
1. Select a text frame on the master spread.
2. Run a menuAction to transform a text frame to a primary text frame.
Lookup the menuAction's name from the context menu after you selected a text frame on a master spread.
Warning! I tried exactly that, but it crashed my InDesign severely.
… ( some minutes later : ) …
Ah. I think I can tell why my InDesign was crashing:
In the moment I was invoking the menu action the master spread was not the active spread.
So make sure that the master spread is the active spread!
Other suggestion that is working:
Add a new document where you define a primary text frame.
Duplicate the master spread to your document where you need the primary text frame.
Use the duplicated master spread instead of the one you already have.
( Tested with InDesign CS6 8.1.0 on OSX 10.10.5. )
Thanks for the suggestion, i did with menuAction method (invoke).
app.menuActions.item("Primary Text Frame").invoke();
Thank you so much this,
I hope that you are spared from crashes.
Just another comment on the problem:
DOM documentation is suggesting—at least I do interpret it this way—that one should be able to assign a pageItem ( text frame or text path ) as value to property masterSpread.primaryTextFrame . However, this is not working. It is always throwing an error. The documentation is showing that this property is r/w . Maybe other factors must be in order that this would work, but they are not mentioned.
I also tried to set the preferences of the document in advance, but this seems to be not sufficient:
doc.documentPreferences.createPrimaryTextFrame = true;
For all scripters working with or for locale versions of InDesign, the string for the menu action that should work on all desktop versions of InDesign—e.g. my German version—is: