This is a very quick article with a code snippet on how I added to a multi-lookup field.
Why?
Using a multi-line or text is possibly a quicker solution and when using a desktop interface, you can parse the multi-line into a nice HTML table. But on a mobile device, it's somewhat better to use the built-in interfaces provided by Zoho Creator.
What I really needed was a way to display the line items from a package slip taken from Zoho Inventory. I'd prefer if it was included in the list view or a Zoho Creator report.
How?
We would think it similar to a picklist/dropdown where you simply add an option to the picklist and then specify which of the options are selected. In this case, simply giving it the IDs should work... but it doesn't.
Assuming my multi-lookup field is called "Zoho Inventory Package Slips" and I'm adding these to a Creator form called "Appointment", my code should be something like the following:
copyraw
	
//
// get 100 most recent appointments where this field hasn't been populated
l_Appointments = Appointment[Zoho_Inventory_Package_Slips == null] sort by Added_Time desc range from 0 to 100;
for each  c_Appt in l_Appointments
{
	//
	// get package references specified in a previous multi-line text field
	l_PackageRefs = c_Appt.Associated_Package_Slips1.toList();
	//
	// important to declare this as a list of integers
	l_PackagesToAdd = List:Int();
	for each  v_PackageRef in l_PackageRefs
	{
		//
		// fetch the package record
		c_Package = Zoho_Inventory_Package_Slips[ZI_Package_Ref == v_PackageRef];
		if(c_Package.count() > 0)
		{
			l_PackagesToAdd.add(c_Package.ID);
		}
	}
	c_Appt.Zoho_Inventory_Package_Slips=l_PackagesToAdd;
}
	- //
- // get 100 most recent appointments where this field hasn't been populated
- l_Appointments = Appointment[Zoho_Inventory_Package_Slips == null] sort by Added_Time desc range from 0 to 100;
- for each c_Appt in l_Appointments
- {
- //
- // get package references specified in a previous multi-line text field
- l_PackageRefs = c_Appt.Associated_Package_Slips1.toList();
- //
- // important to declare this as a list of integers
- l_PackagesToAdd = List:Int();
- for each v_PackageRef in l_PackageRefs
- {
- //
- // fetch the package record
- c_Package = Zoho_Inventory_Package_Slips[ZI_Package_Ref == v_PackageRef];
- if(c_Package.count() > 0)
- {
- l_PackagesToAdd.add(c_Package.ID);
- }
- }
- c_Appt.Zoho_Inventory_Package_Slips=l_PackagesToAdd;
- }
Error(s:
Previously my code below was used and it wouldn't work. The difference to the above is that I was trying to add to the multi-lookup directly:
copyraw
	
//
	for each  v_PackageRef in l_PackageRefs
	{
		//
		// fetch the package record
		c_Package = Zoho_Inventory_Package_Slips[ZI_Package_Ref == v_PackageRef];
		if(c_Package.count() > 0)
		{
			c_Appt.Zoho_Inventory_Package_Slips.add(c_Package.ID);
		}
	}
// doesn't work
	- //
- for each v_PackageRef in l_PackageRefs
- {
- //
- // fetch the package record
- c_Package = Zoho_Inventory_Package_Slips[ZI_Package_Ref == v_PackageRef];
- if(c_Package.count() > 0)
- {
- c_Appt.Zoho_Inventory_Package_Slips.add(c_Package.ID);
- }
- }
- // doesn't work
Source(s):
Category: Zoho :: Article: 820
	

 
			      
						  
                 
						  
                 
						  
                 
						  
                 
						  
                 
 
 

 
 
Add comment