Creating contact with appropriate fields

I have a NewContactButton tiddler with a tag $:/tags/PageControls. It carries the following code:

\define newContact()
    <$action-sendmessage
        $message="tm-new-tiddler"
        title="New Contact"
        tags="Contact"
        works-at="ABC"
        code="XYZ"/>
\end

<$button class=<<tv-config-toolbar-class>> selectedClass="tc-selected" tooltip="New Contact" actions=<<newContact>>>
  {{$:/core/images/quote}}
</$button>

When I click on the button and create a contact, all fields, etc. are visible with default values.

But when I click link to a non-existing tiddler, I need to remember to enter all the fields, etc.

Is there a way by which I can execute that macro when I start editing this newly created tiddler?

desh

When you do follow a “missinglink” and see a missing tiddler, the view template is still used.

If you create a tiddler tagged $:/tags/ViewTemplate With content like this

<$list filter="[all[current]is[missing]]" variable=nul>

Content for responding to missing tiddlers including buttons to create a tiddler like a contact with the currentTiddler name (ie the missing tiddler)

</$list>

I would modify the new contact button to use current Tiddler if not provided so the same button can be used when creating using “New Contact” or when Changing a missing tiddler into a contact. In fact always designing macros and buttons to operation on the CurrentTiddler is a good design approach because the become more reusable.

By this, I thought you meant that I include all the code that generates the ‘New Contact’ button that I had posted in my original post.

So, I did that. Hoping to see ‘New Contact’ button somewhere when I start editing a non-existent tiddler. But I am afraid, I did not see any.

Look like, I am doing something wrong.

How do I set things right?

Here is a working example.

New contact on Missing links.tid (483 Bytes)

Download a working example and drop on your wiki. Follow a link to a missing tiddler and see this appear on the missing tiddler. I made it look like a button so its obvious.

1 Like

I just generalised this as a missing tiddler view template.

Missing-tiddler-view-template.json (412 Bytes)

Tones,

Thanks. This seems to work as expected. As an experiment, I added one more ‘New Contact’ button and it worked, too.

A minor thing, though. \define newContact() and <<currenTiddler>> appear on the new tiddler box. See the attached image.

I guess this is coming from my ‘New Contact’ button.

How can I fix this up?

Desh,

Please use the code icon to display any code in your posts otherwise they are unreadable.

It may be occurring twice if you still have the view template in draft mode or another unfinished tiddler, with the view template tag. I cant be sure what is happening on your wiki. Look at the tiddlers in your recent tab and look inside each to see where the define is in use perhaps.

Tones,

Thanks.

I had used the code icon. My original posts displays clearly here. And I will be careful to apply the icon.

I am not worried about the icon for new contact appearing twice. But that etc. appearing is what I am not able to explain.

\define is used in the ‘New Contact’ button that I had posted in the original post.

1 Like

Update for those who might be interested, you may also want to exclude system and shadow tiddlers.

<$list filter="[all[current]is[missing]!is[system]!is[shadow]]" variable=nul>
... button
</$list>
1 Like

Hi @deshmukh

If the \define ... is visible, it’s probably because there is something else before the \define... in the tiddler code.

For pragmas - like \define - to work, they must be placed at the beginning of the tiddler’s text, before any other wikitext.

Fred

Oooops! Looks like my answer is two years late… :sweat_smile:

1 Like

There is already a template-list plugin that can apply pre-defined fields to a new tiddler

Demo: 模板列表 — 为新创建的条目提供飞书文档风格的模板列表。
CPL: TW-CPL — 太微插件聚合中心

Also a super-tag plugin to show pre-defined fields based on tag GitHub - tiddly-gittly/super-tag: Define schema for a tag, add tag to get a form based on schema.