# Lookup Functions Error: Unexpected null value

**URL:** <https://forum.cloverdx.com/t/lookup-functions-error-unexpected-null-value/1555>\
**Category:** CloverDX Platform\
**Created:** [January 19, 2015, 12:00am UTC](https://forum.cloverdx.com/t/lookup-functions-error-unexpected-null-value/1555 "2015-01-19T00:00:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yichuansancun](https://avatars.discourse-cdn.com/v4/letter/y/8e7dd6/32.png) [@yichuansancun](https://forum.cloverdx.com/u/yichuansancun)\
**Post date:** [January 19, 2015, 12:00am UTC](https://forum.cloverdx.com/t/lookup-functions-error-unexpected-null-value/1555/1 "2015-01-19T00:00:00Z")

</div>

See attached graph. I am getting the following error:

```auto

    9: $out.0.WD_Ref = lookup(Citizenship).get($in.0.c_country, $in.0.c_citizenship_status).WD_Ref_ID;
 
    ----------------------- CTL2 snippet -----------------------
     Unexpected null value.
----------------------------------------------------------------------------------------------------------
ERROR [main] - Execution of graph failed !

```

The ‘WD\_Ref\_ID’ has “^^^^^^^^^^” underneath it.

What did I do wrong ☹

- [Lookup Functions.grf](https://cdn.cloverdx.com/forum/17874%5F30a07ad74c0fc04e625ba1d1741f3c02/Lookup%5FFunctions.grf)

---

<div class="post-metadata">

**Author:** ![slechtaj](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@slechtaj](https://forum.cloverdx.com/u/slechtaj)\
**Post date:** [January 20, 2015, 9:48am UTC](https://forum.cloverdx.com/t/lookup-functions-error-unexpected-null-value/1555/2 "2015-01-20T09:48:25Z")

</div>

Hi,

could you please attach the whole project (including data sample).

Thanks!

---

<div class="post-metadata">

**Author:** ![yichuansancun](https://avatars.discourse-cdn.com/v4/letter/y/8e7dd6/32.png) [@yichuansancun](https://forum.cloverdx.com/u/yichuansancun)\
**Post date:** [January 20, 2015, 7:52pm UTC](https://forum.cloverdx.com/t/lookup-functions-error-unexpected-null-value/1555/3 "2015-01-20T19:52:34Z")

</div>

Here you go! Thanks!

- [LookupFunctions.zip](https://cdn.cloverdx.com/forum/17874%5F755e352be2846e9251162a11c2c0f1e6/LookupFunctions.zip)

---

<div class="post-metadata">

**Author:** ![yichuansancun](https://avatars.discourse-cdn.com/v4/letter/y/8e7dd6/32.png) [@yichuansancun](https://forum.cloverdx.com/u/yichuansancun)\
**Post date:** [January 20, 2015, 10:47pm UTC](https://forum.cloverdx.com/t/lookup-functions-error-unexpected-null-value/1555/4 "2015-01-20T22:47:20Z")

</div>

I solved the problems, I changed the code to the following and worked:

```auto
if(lookup(Citizenship).get($in.0.c_country, $in.0.c_citizenship_status) == null)
	{ $out.0.WD_Ref = "not found";}
	else 
	{
	$out.0.WD_Ref = lookup(Citizenship).get($in.0.c_country, $in.0.c_citizenship_status).WD_Ref_ID;}

```

---

<div class="post-metadata">

**Author:** ![dpavlis](https://avatars.discourse-cdn.com/v4/letter/d/90ced4/32.png) [@dpavlis](https://forum.cloverdx.com/u/dpavlis)\
**Post date:** [January 21, 2015, 10:44am UTC](https://forum.cloverdx.com/t/lookup-functions-error-unexpected-null-value/1555/5 "2015-01-21T10:44:57Z")

</div>

You can also use [CTL’s conditional fail expression](http://doc.cloveretl.com/documentation/UserGuide/topic/com.cloveretl.gui.docs/docs/conditional-fail-expression-ctl2.html).

The code would look like this:

```auto

$out.0.WD_Ref = lookup(Citizenship).get($in.0.c_country, $in.0.c_citizenship_status).WD_Ref_ID : "not found";

```
