Schedule Walk-Up Appointment using REST API

Sahil Khan1
Tera Guru

Hi Community,

I’m working on a requirement to create a walk-up appointment using REST API. I initially planned to use a record producer to achieve this, as it aligns well with the existing form design. However, I’ve encountered a challenge:

The record producer includes a custom variable that’s tied to a custom widget (used for user selection and input). When trying to create the record via the REST API, I’m unable to pass data into this variable/widget. It appears that the custom widget does not accept input directly through the standard record producer REST endpoint.

Additionally, I considered using the Table API, but there are business rules and logic triggered by the record producer that I don’t want to bypass.

My questions are:
1. Is there a way to pass data to a custom widget variable via REST when using a record producer?
2. If not, what would be the recommended alternative to create walk-up appointments Using REST API?
3. Is there a clean way to invoke the record producer server-side logic (e.g., using a Scripted REST API or Flow) while accepting input via REST?

In attached photo I have already passed every mandatory field data but getting error

Additionally we are able to create record in walk up table using table API but not able to populate appointment data if we enforcing it giving some error

Any guidance or best practices would be greatly appreciated!

Thanks in advance.

4 REPLIES 4

JenniferRah
Mega Sage

I'm not sure what you mean by the variable is in a custom widget, but from your JSON, it looks like you are using a variable set. I had to submit a catalog item via server-side code that had a MRVS, and I found that you can't set that when you create it. I had to create the record and then send an update with the MRVS info immediately after submitting. I'm not sure if that is what you need, but my code looked something like this:

 

    var cart = new Cart(); //Create cart
    var item = cart.addItem(sysIdOfCatalogItem); //add catalog item
    var rc = cart.placeOrder(); //submit cart
    var mrvsData = [];
    mrvsData.push({
        "asset_item_requested": "Laptop",
        "asset_quantity_requested": "5"
    });
    var mrvsJsonString = JSON.stringify(mrvsData);
    var ritmId = getRITM(rc.sys_id);
    var ritm = new GlideRecord('sc_req_item');
    ritm.get(ritmId);
    ritm.variables.assets = mrvsJsonString; //Assets was the name of my MRVS
    ritm.update();

function getRITM(serReq) {
    var ritm = '';
    var grRITM = new GlideRecord('sc_req_item');
    grRITM.addQuery('request', serReq);
    grRITM.query();
    if (grRITM.next()) {
        ritm = grRITM.sys_id;
    }
    return ritm;
}

 

My code was a scheduled job, but you could do something similar in a custom Scripted REST API where you send the information and parse it out to do something similar. I hope that helps.

Sahil Khan1
Tera Guru

Thanks for your response @JenniferRah 
But it is not relatable for me 
OOB Record Producer name: SC Walk-up Appointment
Sys_id: 12c7f431b3731300eda5a72256a8dc5b
Variable is custom type which is associated with a widget named 'Appointment Booking - Select '.  

You lost me there. You say this is an OOB Record Producer, but I don't see one with that name in my instances. I'm not sure if you meant it was a custom one or if it's tied to a plugin I don't have installed.

 

Either way, if this is a variable on a widget that is only visible/available on the portal, then there's not going to be a way to populate that variable with a REST call. A REST call is creating the record itself or filling out the record producer as it exists on the platform.

 

If this variable is being used to calculate something or look something up, your code will need to do that on the back end instead of trying to fill in the variable. I hope that makes sense with your scenario. 

Hello @JenniferRah 
Thanks for your response,
Yes it is tied with Plugin 
this field/widget(widget associated with the field) checking appointment availability