Forum Discussion
How to create Hyperlink within an if{}
Hello,
i have the following problem:
a Word-document contains some REF values like "isNewCustomer". The text should show a textblock with an hyperlink only for new customers. I tried IF {} in two ways:
- enclose the whole text-block including hyperlink, so the HYPERLINK {} is inside the IF{}
- use a hyperlink that has the IF {} inside the HYPERLINK{}
I hope i transfered my code fully to this answer because fieldfunctions can noct be copied into text.
The text should apper for new customer as
Hello customer,
you can user our services. As new customer you have to register first via "https://email address removed for privacy reasons". After registration...
For an existing customer it should be
Hello customer,
you can user our services. After registration...
I tried as follows:
Hello customer,
you can user our services. { IF { REF isNewCustomer } = "true" "As new customer you have to register first via { HYPERLINK "https://email address removed for privacy reasons" } } After registration...
With this way of code the hyperlink included in the IF {} appears as pure text, not as a link.
Then I tried to build different text-blocks:
- at first a text - block for all customer without any if{}
- after that the text for new customers with an if {} and without any link
- after that the hyperlink for new customers that contains an if{} in the HYPERLINK field function to show the hyperlink if it is an new customer and an empty string if it is not a new customer
- after that the text that should appear after the link
Hello customer,
you can user our services. { IF { REF isNewCustomer } = "true" "As new customer you have to register first via " } HYPERLINK { IF { REF isNewCustomer } = "true" "https://email address removed for privacy reasons" ""} } After registration...
In this way of code the link cannot been empty in the case that "isNewCustomer = "false". When false I get "wrong hyperlink" because HYPERLINK { IF {...} is parsed as HYPLERLINK { "" }. It is the same when leaving the third paramter of the IF empty (HYPERLINK { IF { true "Link" } }.
If the newCustomer REF is true the hyperlink is shown as link but I can't edit an other text. The short hyperlink here is only an example. The real link is about 200 characters long and should by displayed as "klick here" and open the real link by klick.
Ist there any way in Office 365 to fill in a hyperlink only if a REF variable has the suitable content, show an other text for the link and leave all blank if the REF doesn't fit?
Many thanks
Siegbert
6 Replies
siegbert Can you upload a copy of the document in which you have the new customer text and the hyperlink inside the If..then...Else field construction. That is the way to go and we will investigate why it is not working for you.
- siegbertCopper Contributor
Doug_Robbins_Word_MVP How can I upload a document? I didn't find an upload-button. If I drag&drop the document i get "the file type (.docx) is not supported." in an oteher thread someone wrote, that this is not allowed for new members.
So I Try to post a graphic screenshot of the document showing the problem:
This is show as:The Link in Test 4.1 works, but it is not possible to show "no Link". Than i get the error message "Fehler: Linkreferenz ungültig" in english: error invalid link reference
best regards
Siegbert