Hello Salih,
I'm not sure if this helps, but you can pass parameters to the Job Execution file using the %global macro variable, and it can return whatever you need. Below is an example of what I imagine you're trying to do — maybe it helps you understand the logic so you can apply it in your daily work.
Query API to return the 'where' parameter
cas;
caslib _all_ assign;
options casdatalimit=all;
%global year;
%global month;
proc sql;
create table result as
select
year_out
from public._date_range
where year_in = &year.
and month_in = &month.;
quit;
proc json out=_webout nosastags pretty;
export result;
run;
In the job file parameters, make sure to set the output to JSON:
_output_type: json
Then, link the first "selection" to the search parameter using JavaScript in another job file — in this case, it's just using HTML.
async function updateEndFields() {
const selectedYear = yearStart.value;
if (!selectedYear) return;
yearEnd.innerHTML = '<option>Loading...</option>';
yearEnd.disabled = true;
try {
const resYear = await fetch(`/SASJobExecution/?_program=[job_exec_link]&year=${selectedYear}`);
const yearData = await resYear.json();
yearEnd.innerHTML = '';
const optYear = document.createElement('option');
optYear.value = yearData[0].year_out;
optYear.textContent = yearData[0].year_out;
yearEnd.appendChild(optYear);
yearEnd.disabled = false;
} catch (error) {
console.error('Error updating end fields:', error);
yearEnd.innerHTML = '<option>Error</option>';
}
}
yearStart.addEventListener('change', updateEndFields);
I created it using just one parameter as an example, but you can easily extend it to handle more.
I hope this helps you!
... View more