# Call "Link call" from function

**URL:** <https://discourse.nodered.org/t/call-link-call-from-function/71651>\
**Category:** General\
**Tags:** function-node\
**Created:** [3 December 2022 21:03 UTC](https://discourse.nodered.org/t/call-link-call-from-function/71651 "2022-12-03T21:03:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![S0T0](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@S0T0](https://discourse.nodered.org/u/S0T0)\
**Post date:** [3 December 2022 21:03 UTC](https://discourse.nodered.org/t/call-link-call-from-function/71651/1 "2022-12-03T21:03:48Z")

</div>

Is it possible to call "link call" from a function and then work with what it returns?

 ![Screenshot 2022-12-03 at 22.02.52](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/2/5209d39a54019ff0ac7ac85d1f37f69dda3eb7a9.png)  
Thank you and take care!

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [3 December 2022 21:05 UTC](https://discourse.nodered.org/t/call-link-call-from-function/71651/2 "2022-12-03T21:05:28Z")

</div>

Hi @S0T0

No, it is not possible to do that.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [3 December 2022 21:57 UTC](https://discourse.nodered.org/t/call-link-call-from-function/71651/3 "2022-12-03T21:57:42Z")

</div>

Split the function in two and call the link in the middle.

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [4 December 2022 17:54 UTC](https://discourse.nodered.org/t/call-link-call-from-function/71651/4 "2022-12-04T17:54:59Z")

</div>

> [@S0T0](#):
>
> work with what it returns

If you really want everything in one `function` node (although not all in JavaScript), you could do this. Not seriously recommended.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/2/7242ceee2bba6d9a61336d85da9edb3673e8ad90.png)

```auto
[{"id":"58a0314dfaabdb02","type":"function","z":"e4d8efb5c97ba927","name":"function","func":"if (!msg._return) {\n// start function \n// optional, if link-call has dynamic target\n// msg.target = 'subroutine'\n msg._return = true\n return [null,msg]\n} else {\n// finish function\n delete msg._return\n return[msg,null]\n}\nreturn msg;","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":140,"wires":[["d220d81a2fe06190"],["3335886b6ff7993b"]]},{"id":"ee833ab0cd37a661","type":"inject","z":"e4d8efb5c97ba927","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":140,"wires":[["58a0314dfaabdb02"]]},{"id":"3335886b6ff7993b","type":"link call","z":"e4d8efb5c97ba927","name":"call subroutine","links":["ad7e14fffdc6f4fc"],"linkType":"static","timeout":"30","x":500,"y":160,"wires":[["a6c69fc023067e09"]]},{"id":"d220d81a2fe06190","type":"debug","z":"e4d8efb5c97ba927","name":"continue","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":480,"y":120,"wires":[]},{"id":"ad7e14fffdc6f4fc","type":"link in","z":"e4d8efb5c97ba927","name":"subroutine","links":[],"x":125,"y":220,"wires":[["b17ed7c9d1315020"]]},{"id":"d51c500e4fdb9c72","type":"link out","z":"e4d8efb5c97ba927","name":"link out 11","mode":"return","links":[],"x":335,"y":220,"wires":[]},{"id":"b17ed7c9d1315020","type":"function","z":"e4d8efb5c97ba927","name":"subroutine","func":"// subroutine code\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":230,"y":220,"wires":[["d51c500e4fdb9c72"]]},{"id":"a6c69fc023067e09","type":"junction","z":"e4d8efb5c97ba927","x":440,"y":220,"wires":[["58a0314dfaabdb02"]]}]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [18 December 2022 17:55 UTC](https://discourse.nodered.org/t/call-link-call-from-function/71651/5 "2022-12-18T17:55:24Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
