Accessing values from an RPC call in a custom IML function

I am trying to write a custom IML function that will parse a set of dates from fields. The difficulty comes from the fact that the fields are not known in advance, but rather, they come from an RPC and I’ll be getting a mixture of date and non-date fields.

A similar problem is already covered in the Custom Apps Development Training videos, with a significant difference - the fields there are known in advance. That does not apply for me and thus the solution is not directly applicable.

What I would like to do is to have my IML function access the result from the RPC call that gets the fields, so that I can then figure out which of the fields are dates and thus which should be parsed as such. So the function would look something like this:

function parseAllDates(parameters) {
  // This next line is what I'm trying to figure out!
  const dateParameters = rpc.getFields.map(field => field.name)
  
  Object.entries(parameters).forEach(entry => {
    // The actual parsing logic is identical to the one in the video
    ...
  });
  return parameters
}

So ultimately my question boils down to - is there any way in which I can access the result of RPC calls from an IML function that parses the parameters ahead of sending them to the server? If there is, I haven’t been able to find it in either the text documentation or the videos.

I’ve gone with a bit of a roundabout way to implement this. When fetching the fields from the RPC call, I am giving them a custom prefix:

function markDates(fields) {
  return fields.map((field) => {
    if (field.type === "date") {
      return { ...field, name: "__date__" + field.name, value: "__date__" + field.value }
    }
    return field
  })
}

Knowing that all the date fields will have this prefix means that I can then distinguish them easily when I have to parse the values:

function parseDates(parameters) {
  const newParameters = {}
  
  for (const [name, value] of Object.entries(parameters)) {
    if (!name.startsWith("__date__")) {
      newParameters[name] = value
    } else {
      const cleanName = name.slice(8)
      newParameters[cleanName] = value ? iml.parseDate(value) : null
      delete newParameters[name]
    }
  }

  return newParameters;
}

I’m still keen to figure out if this can be achieved without the first renaming step, but otherwise, this is good enough for me!