Deluge Workflow: Cannot insert and retrieve a new record
I've got a calendar app that lists events for different high school sports. It needs to import non-standardized excel spreadsheets - the school does not force standardized sheet layout from each coach - and create events for the season. I do some manual data cleaning before importing but for obvious reasons I don't want to manually do every event.
Adding an event requires the user to enter a date time, an opponent, and a location school name (not address), but many coaches just write "here" or "there" for location instead of the actual location...
The code below attempts the following - if "here", then replace location field with the school name. If "there", 1) check to see if location exists 2) if yes, change field value, 3) if no, Add the record to the Location form and then change the field value to the newly added location. Parts 1 and 2 work just fine, but I cannot get Zoho to insert the new record and retrieve it... any thoughts?
Problem is lines 20-30. This code is in the Events form, triggered "on Success".
- LocHome = "HERE";
- LocAway = "THERE";
- Opp = input.Opponent.Opponent_Name;
- LocVal = Location[Location_Name.equalsIgnoreCase(Opp)];
- if(Location.Location_Name.equalsIgnoreCase(LocHome))
- {
- //If Location is "here", make location field equal to School name.
- LocVal = Location[Location_Name.equalsIgnoreCase(input.School.School_Name)];
- input.Location = LocVal.ID;
- }
- else if(Location.Location_Name.equalsIgnoreCase(LocAway))
- {
- //See if Opponent exists in Location list. If yes, change value of Location field to Opponent name
- if(LocVal != null)
- {
- input.Location = LocVal.ID;
- }
- //if it does not exist, create the location and change value of Location field to Opponent name
- else if(LocVal = null)
- {
- insert into Location
- [
- Added_User=zoho.loginuser
- Location_Name=input.Opponent.Opponent_Name
- ];
- NewLocRecord = Location [ Location_Name == input.Opponent.Opponent_Name ];
- input.Location = NewLocRecord.ID;
- }
- }