Skip to main content

Does anyone have any examples of running an Ajax call to an Apex class that returns data and use that data within a Skuid table? 

My use case:
I have a medical data provider that allows httprequests with a webservice to get data (Pharmacies, hospitals, medications etc.). The data is updated daily as new meds, pharmacies come out all the time. I want to present my users with a SKUID lookup table that is searchable and filtered and allow row actions to allow the user to add the lookup record to salesforce and associate the newly added record to the account.

Is there a way to do this or should I maintain a copy of 100’s of thousands of lookup data in an object?

Just something basic that calls apex which returns JSON or something and then make it a dummy Skuid model or something… 🙂

Personally, I’d create an object simply to hold the data and easily display it in components. I’d then parse the JSON in order to put it into the model. I bet you can even mess with the model in order to make the component display the data as if it came from existing records. ie. remove the entries from the Changes and update hasChanges property to false.

You can even use table filters to customize the ajax call by creating a javascript snippet that is called on the Model being requeried. The snippet can be used to loop through the conditions to update the ajax call.

Dunno, ajax and apex to me are somewhat foreign to me. 😛


Do you know if the medical service provider provides REST/JSON services or just SOAP/XML?


Just another suggestion…this sounds like a use case for Lightning Connect.  Once the connection is made, Salesforce exposes the connection just like any other object (i.e. Account, Contact; etc.).  You should be able to use standard Skuid pages from there (that is create a model in Skuid by selecting the ‘object’ created by Lightning Connect).


My understanding is that Lightning Connect is $5000/month. Maybe it’s changed, but that’s the last time I checked. 😦


Its using SOAP/XML. I have a visual force page with controllers that do the lookup and show it in a VF Page but I would like the page to not stick out as much and be executed from Skuid. Ideas?


Here is what the API Documentation has which isn’t much.


Web Service Method: GetPharmacyDS, GetPharmacyXML, GetPharmacyObjGet Pharmacy XML Data Set
Input Parameters:
 Pharmacy Object – Pharmacy Search Object with properties to search. Values can be entered
into one or more properties and all will use a LIKE starts with query. For example to search for
all Pharmacies that start with “Wal” in California, pass the object with Pharmacy.Name = “Wal”
and Pharmacy.State = “CA”.
 Only Active – Boolean – pass true to have search results only contain active current Surescripts
Pharmacies. Pass false to return both active and inactive/no longer subscribing Pharmacies
 Boolean Flags for which types to include – pass false if you want to exclude a certain type –
bool IncludeRetail, bool IncludeMailOrder, bool IncludeFax, bool
IncludeSpecialty, bool IncludeLongTerm, bool IncludeTwentyFourHour.


Note: if you include mail order pharmacies you will get pharmacies
that do not match the demographics (city, state or zip)passed in. Mail
order pharmacies will match on name but not demographics per the
requirement that all pharmacies that a patient can use in their
neighborhood also include mail order pharmacies that can mail
prescriptions to them.

 Account Object – pass the Account Object specifying Account Id and Authorization info.
 Out Status – Out Parameter Status Object will be filled with Status.Success if the operation
successed and xml data is being returned. Will return Failure if there was any problem getting
the data. Status Message will be filled with the Failure Message
 Out Status Message – Out Parameter String – Will return any error message if there was a
problem getting the data


Output/Return Value:
 XML DataSet – If Successful the routine will return an XML DataSet. Dataset will be limited to
first 100 matches sorted by Pharmacy Name, columns:
o NCPDPID – the unique id of the pharmacy
o StoreNumber
o Name
o Address1
o Address2
o City
o State
o Zip
o Phone
o Fax
o Email
o Cross Street
o PharmacyType (string) e.g. Retail TwentyFourHour
o Service Level (integer)
o Service Level Desc (string) e.g. NewRx Refill
o SpecialtyType
o ActiveStartTime – when they signed up with Surescripts
o ActiveEndTime – if they are no longer active w/Surescripts / end date
o Active – small int – 0 / 1 Flag for active or not
o Status – varchar(1) – “A” for Active, “I” for Inactive, etc.


Example Method Call:
C#.Net
//get the Pharmacy searcher object – search by name, city state or zip
rxws.Pharmacy PharmSearchObj = new WebApp1.rxws.Pharmacy();
PharmSearchObj.StoreName = sName;
PharmSearchObj.City = sCity;
PharmSearchObj.State = sSt;
PharmSearchObj.Zip = sZip;
//call the webservice that will return the matches
DataSet ds = oRxWS.GetPharmacyDS(PharmSearchObj, true, true, true, true, true true,
WsAcctObj, out Status, out StatusMsg);
if (Status == WebApp1.rxws.Status.Success && ds.Tables.Count > 0)
{
//bind returning xml dataset to display pharmacy results …



VB.Net
'search by name, address city state zip or phone per user input
Dim PharmObj As MDTBrx.Pharmacy = New MDTBrx.Pharmacy()
PharmObj.StoreName = sName
PharmObj.Addr1 = sStreet
PharmObj.City = sCity
PharmObj.State = sState
PharmObj.Zip = sZip
PharmObj.Phone = sPhone
Dim StatusFlag As MDTBrx.Status
Dim StatusMsg As String
'call the webservice to get the xml dataset – do not include mail order
ds = rxws.GetPharmacyDS(PharmObj, False, true, false, true, true true, wsAcctObj,
StatusFlag, StatusMsg)
If StatusFlag = MDTBrx.Status.Success Then