How to search a specific field of an entity using numpad

I’m having similiar issue with this post I can't understand the reason, magical Numpad Select

Using my current action, Entity Search Value will search all fields of entities. Is it possible to stop SambaPOS search all fields and only search Loyal Card ID field instead?

image

Can you show your entity configuration?

1 Like

It’s in a custom language, however there’s nothing special. Just basically default stuff.

Entity Types > General Settings
— Name: Customers
— Entity Name: Customer
— Primary Field Name: CustomerID

Entity Types > Custom Fields
— FullName
— MobilePhone
— LoyalCard

In my case, I want numpad search only work when all numbers in LoyalCard are input fully and correctly.

Ok, my setup is similar.
I use a script to get the customer entity name using the custom field meaning rather than using search just set the entity directly;

Script; - could probably be improved, was done before graphql api implimented.

function checkId(inputId,currentUser) {
    var customerName            = 'Invalid Swipe';
    var customerCount            = sqlEntityCount('Customers');
    var customerList            = sqlEntityList('Customers');
    for (var c = 0; c<customerCount; c++) {
        var loopCustomer            = customerList[c];
        var loopCustomerFobId        = api.Entity(loopCustomer).Data('Fob Number').Get();
        if (inputId === loopCustomerFobId) {
            var loopCustomerIsStaff            = api.Entity(loopCustomer).Data('Staff Member').Get();
            if (loopCustomerIsStaff == '') {        
                var customerName            = loopCustomer;
                } else {
                var loopCustomerStaffUser    = api.Entity(loopCustomer).Data('Staff User').Get();
                if (loopCustomerStaffUser==currentUser) {
                    var customerName            = 'Own Fob';
                    } else {
                    var customerName            = loopCustomer;
                    }
                }
            break;
            }
        }
    return customerName
}


function customerPriceListTag(inputCustomerName) {
	var customerPriceListTag	= api.Entity(inputCustomerName).Data('Price List Tag').Get();
	if (customerPriceListTag) {
		var response			= customerPriceListTag;
		} else {
		var response			= 'No Price List Defined';
		}
	return response
}

function sqlEntityCount(inputEntityType) {																												//--Entity count by entity type
	qry =  " SELECT COUNT([Name]) as [CT] 							";
	qry += " FROM [Entities] 										";
	qry += " WHERE [EntityTypeId]= 									";
	qry += "					(									";
	qry += "					SELECT [Id]							";
	qry += "					FROM [EntityTypes] 					";
	qry += "					WHERE [Name]='"+inputEntityType+"' 	";
	qry += "					) 									";																					//--QRY Variable + 'roomEntityType' Variable
	var entityCount = sql.Query(qry).First;																												//--SQL Query responce -> entityCount Variable
	return entityCount;																																	//--Return
}

function sqlEntityList(inputEntityType) {																												//--Entity list by entity type
	qry =  " SELECT [Name] 											";
	qry += " FROM [Entities] 										";
	qry += " WHERE [EntityTypeId]= 									";
	qry += "					( 									";
	qry += "					SELECT [Id] 						";
	qry += "					FROM [EntityTypes] 					";
	qry += "					WHERE [Name]='"+inputEntityType+"'	";
	qry += "					) 									";
	qry += " ORDER BY [Name]										";																					//--QRY Variable + 'roomEntityType' Variable
	var entityList = sql.Query(qry).Delimit('~').All;																									//--SQL Query responce -> entitiesList Variable (~ seperated list of entities)
	return entityList;																																	//--Return
}

Numberpad value entered rule triggering seccond rule with script response as command value;

Ok on ask question selects customer in this rule;

command rule if script returns valid customer name;

Its for ‘vip’ price list so if no price list field set returns error here;

I have another custom field where you can put in a samba username - ie for staff discount fobs you can put in there samba username to prevent them swipping their own fobs to give others their stadd discount while working;

1 Like

This setup was done a while back, i went this route rather than entity search as wanted those additional automation flow routes for different constraints.
Also as said could probably be simplified if i went back and redid it however has works fine for last 3 years so havn’t bothered updating.
Could definatly remove the need for direct sql queries by using some form of report expression to input the entiy list within the script call, but again, woks as it is LOL

1 Like

Wow, this looks massive for my ability. Thank you so much. I’ll have this weekend trying out your guide. :star_struck: