# How to fetch data from DAI as value

**URL:** <https://forums.eggplantsoftware.com/t/how-to-fetch-data-from-dai-as-value/8725>\
**Category:** Uncategorized\
**Created:** [February 21, 2024, 7:09pm UTC](https://forums.eggplantsoftware.com/t/how-to-fetch-data-from-dai-as-value/8725 "2024-02-21T19:09:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhaavan](https://forums.eggplantsoftware.com/letter_avatar_proxy/v4/letter/b/13edae/32.png) [@bhaavan](https://forums.eggplantsoftware.com/u/bhaavan)\
**Post date:** [February 21, 2024, 7:09pm UTC](https://forums.eggplantsoftware.com/t/how-to-fetch-data-from-dai-as-value/8725/1 "2024-02-21T19:09:27Z")

</div>

Good day,

I am currently encountering a challenge with data retrieval from DAI, where the data is received as a string (e.g., “true,true”). This data needs to be passed to an API call in a non-string format (e.g., true,true). Given that the values can vary (e.g., “true,Approved,true”), directly using Boolean might not be feasible. I would appreciate any assistance in addressing this issue.

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![Karsten](https://forums.eggplantsoftware.com/letter_avatar_proxy/v4/letter/k/e47c2d/32.png) [@Karsten](https://forums.eggplantsoftware.com/u/Karsten)\
**Post date:** [February 23, 2024, 11:54am UTC](https://forums.eggplantsoftware.com/t/how-to-fetch-data-from-dai-as-value/8725/2 "2024-02-23T11:54:02Z")

</div>

Hey @bhaavan,

- Can you share the sensetalk handler you are using?
- “true,true” is this one parameter or two parameters in DAI.
- Is it script or model based?
- is is a [model parameter](https://docs.eggplantsoftware.com/dai/dai-create-parameters/#action-parameters) or a parameter at a test case?
- How do you enter the parameter string in DAI? Can you share a screenshot?  
In case you have one string “Karsten,Wenzke,Keysight”. you need to split if by comma in your handler

```auto
on MyHandler varA
Split VarA by comma
put varA // should be a list now
Put item 1 of VarA
end 

```

Here an example handler that should work for two parameter of a [model action](https://docs.eggplantsoftware.com/dai/dai-create-parameters/#action-parameters)

```auto
on MyHandler varA, VarB
put varA
put varB
end myHandler

```

Cheers,  
Karsten

---

<div class="post-metadata">

**Author:** ![bhaavan](https://forums.eggplantsoftware.com/letter_avatar_proxy/v4/letter/b/13edae/32.png) [@bhaavan](https://forums.eggplantsoftware.com/u/bhaavan)\
**Post date:** [February 26, 2024, 10:30am UTC](https://forums.eggplantsoftware.com/t/how-to-fetch-data-from-dai-as-value/8725/3 "2024-02-26T10:30:17Z")

</div>

Hello @Karsten ,  
Thanks for your time .  
PFB answers

- “true,true” is this one parameter or two parameters in DAI.— **one parameter**
- Is it script or model based? — **Model Based**
- is is a [model parameter](https://docs.eggplantsoftware.com/dai/dai-create-parameters/#action-parameters) or a parameter at a test case? ---- **Test Case Parameter**

Screen shot for parameters in DAI

 ![image](https://forums.eggplantsoftware.com/uploads/default/original/1X/7f5f14f2ff7c3ad2bfdbb2b168ff101787548fd9.png)

Currently using handler  
to handle FinalreqData

```
	Params FinalizationText
	put split(FinalizationText,",") into mylist
	put number of items in mylist into itemscount
	if itemscount = 0 then
		put () into Reqdata 	
		
	else
		set icount =1
		repeat itemscount times
			insert item icount of mylist after Reqdata 
			add 1 to icount
		end Repeat
		
	end if		

```

end FinalreqData

---

<div class="post-metadata">

**Author:** ![Karsten](https://forums.eggplantsoftware.com/letter_avatar_proxy/v4/letter/k/e47c2d/32.png) [@Karsten](https://forums.eggplantsoftware.com/u/Karsten)\
**Post date:** [February 29, 2024, 6:58pm UTC](https://forums.eggplantsoftware.com/t/how-to-fetch-data-from-dai-as-value/8725/4 "2024-02-29T18:58:35Z")

</div>

Hey @bhaavan,

Not sure if your questions is solved or not.  
Are you happy with your handler and it is working for you?

It takes the parameter string that by default is one text string as you have defined it.

I do not understand why you have the if statement.  
Mylist is the same as reqdata. a list of n items

here is a handler that might do what you have in mind.

```auto
FinalreqData "true,abc,true" -- same as your DAI parameter

to FinalreqData FinalizationText
	split FinalizationText by comma -- this turns the text into a list
	put FinalizationText -- ["true","abc","true"]
	put number of items in FinalizationText into itemscount -- equals the number of items in the list
	put itemscount -- 3
	-- by default each variable is treated as text and sensetalk determines the type internally when needed. The user does not need to care about it. 
	put !"[[item 1 of FinalizationText]]" -- puts the value true without quotes. you will see just true on the output
end FinalreqData

```

for the merge “!” take a look at these resources:

- [Merge docs](https://docs.eggplantsoftware.com/studio/stk-text-data-manipulation/#merge)
- [Eggplant SenseTalk Merge Video](https://www.youtube.com/watch?v=WO0xU4owQDY&list=PL_XmBTGQNIPvsO5rgFgOhADrgbzC2NmrK&index=21)
- [Suite on Git used in the video above](https://github.com/keysight-eggplant/SenseTalk-Eggspert-Sessions/tree/master/231122-merge)

Kindly ask you to explain what your desired goal is.  
Hope the above is the answer to it. 🙂  
Cheers,  
Karsten
