# How to use set-hook in leaf-list?

**URL:** <https://dmap-community.ductus.global/t/how-to-use-set-hook-in-leaf-list/734>\
**Category:** Core Engine and APIs\
**Created:** [September 23, 2016, 11:43am UTC](https://dmap-community.ductus.global/t/how-to-use-set-hook-in-leaf-list/734 "2016-09-23T11:43:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cheluvaraj](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@cheluvaraj](https://dmap-community.ductus.global/u/cheluvaraj)\
**Post date:** [September 23, 2016, 11:43am UTC](https://dmap-community.ductus.global/t/how-to-use-set-hook-in-leaf-list/734/1 "2016-09-23T11:43:29Z")

</div>

Hi All,

```
 I all. I am using set-hook inside a list as shown in the below code. But yang is not invoking the callback function. I am able to invoke the callback function using container. But I really don;t know why set-hook is not working in leaf-list.

```

Can someone please suggest how to invoke a callback function from leaf-list ?

**leaf-list code, with set-hook not working:**

list set\_channel\_reverse {  
config true;  
tailf:callpoint olt {  
tailf:set-hook subtree;  
}  
key value;  
leaf value {  
type enumeration {  
enum “Disable”;  
enum “Enable”;  
}  
}  
}

**Container code with set-hook working:**

container set\_system {  
leaf host\_msg\_timeout {  
config true;  
tailf:callpoint olt {  
tailf:set-hook subtree;  
}  
type uint16 {  
range “0 … 10000”;  
}  
}  
}

Any help on this would be rally appreciated.

---

<div class="post-metadata">

**Author:** ![nabil](https://avatars.discourse-cdn.com/v4/letter/n/e79b87/32.png) [@nabil](https://dmap-community.ductus.global/u/nabil)\
**Post date:** [September 26, 2016, 8:28pm UTC](https://dmap-community.ductus.global/t/how-to-use-set-hook-in-leaf-list/734/2 "2016-09-26T20:28:46Z")

</div>

Can you share the code where you register callbacks for the hook?

Example:

```
olt_hook.create = olt_hook_create;
olt_hook.remove = olt_hook_remove;
olt_hook.set_elem = olt_hook_set_elem;
strcpy(olt_hook.callpoint, "olt");

```

If you ommit one of the callbacks registration, it will be set to NULL.  
For example if you only register the create and remove callbacks, the set\_elem callback will be set to NULL and you won’t trigger your application code if you set a leaf under an already created list.

So make sur you have the set\_elem callbacks registered as well.

-Nabil

---

<div class="post-metadata">

**Author:** ![bkannadassan](https://avatars.discourse-cdn.com/v4/letter/b/f6c823/32.png) [@bkannadassan](https://dmap-community.ductus.global/u/bkannadassan)\
**Post date:** [March 24, 2017, 4:02am UTC](https://dmap-community.ductus.global/t/how-to-use-set-hook-in-leaf-list/734/3 "2017-03-24T04:02:54Z")

</div>

For me for list callback is invoked but looks like I can’t have more than 1 leaf node. Since for other leaf nodes also it keeps showing the values fetched from the callpoint.

Btw setting mandatory=TRUE does the trick in the list calling the hook function. But not sure why its a must…
