Hey guys, I have a new question.
A bit complex to explain for me, so I request you to read carefully.
Colours- Black - Headings Red - Something Important Orange - Field or cell in my dataset. Blue - Calculations
Database Description - Suppose I have 3 fields in my database: Customer Name, Executive & Follow up Date. The data represents that which executive has to make a call to which customer on which date .
Aim - Think, my Executive 1 is on holidays for 5 days, then it might become a loss for my company that I loose 1 customer named ‘A’ as he was not called on the specified date. Therefore , my aim is that if any customer is not called for more than 2 days then that customer is passed to another executive .
Procedure (I think) -
I have to make a job scheduler that runs every day on the particular dataset.
In the job scheduler, I have to compare today’s date with the date present in the follow-up date column in the dataset that should run for each row (I have 10,000 rows in my dataset).
And if it is found that the difference between the dates (Today’s Date - Date in the field) is more than two days then the Executive of that row gets changed to what I Specify.
For Ex- If Executive 1 has missed 10 calls for that day then 5 calls should be assigned to Executive 2 and other 5 calls should be assigned to Executive 3 .
So that’s it, I hope I will be helped soon.
Thanks in Advance!!
I don’t know whether the procedure I thought would work or there is any other way too. I have just listened about Job Scheduler, that It is made when we make a task in repetition in the backend.
You described what you want to do and it makes sense. but what’s the question? Which part is not clear? Create the scheduled job, create the back-end function that’s makes it. And that’s all.
I don’t know How to do it. @jonatandor35 In the last 1 hours I have checked all the articles about how to schedule jobs and I have understood it, the thing I don’t know what to do with the dataset code.
I don’t know what to write in the .jsw file.
@rinshulgoel the rank field type should be “Number”.
You’ll have to debug the code and figure out what’s not working.
The goal of my code above was only to show a possible direction, but I can’t guarantee there’s no error/problem there, You’ll have to investigate (use the site monitoring tools) and adjust in accordance.
Will this code works only on the first 1,000 items of “Try” dataset as I Have 30,000 items in my dataset. (I have tried WixDataFilter earlier but never tried WixDataQuery before)
Will you please make me understand the logic of how it is changing the executives as -
You see the “Before” and “after” after screenshots of datasets. In the “After” pic you see that the 8th item is unchanged but that should also be changed.
Looking Forward for a response.
I am highly obliged to you thank you.
@rinshulgoel as for the first question. Yes it’ll only work for first 1000 matches.
If you want to make it on over then 1000 matches you should make it in several iterations. (see: here )
Also the bulkUpdate is maybe even more limited (I’m not sure what its limit).
As for your second question, I’ll try to find time to answer it later today.
For you second question. I assumed that the executives in the ReplacingExecutives collection are those who can be available for sure, and those in the Try collection may now be available.
The logics (maybe it doesn’t suit to your needs) is like that:
Find the events that need to change
Find the Executives available for event assignment
The assignment order is by rank - the executive with the highest rank will get the assignment first.
Assign 5 events to the first executive and then move to the second highest rank, assign 5 and move to the next one. etc…
When you run out of available executives, go back to the first one and assign another 5 and then to the next etc…
@jonatandor35 In this can’t we do that if the executive matches then skip that.
Like -
if (present_executive === replacing executive) {
move to next replacing_executive
and then replace the executive
}else {
we have written code for this condition
}
@rinshulgoel you can do it, but you should plan the exact logics. “Move to the next executive” and then what? go back to the previous one? keep proceeding? When you know exactly what you’d like to happen, you’ll be able to write the corresponded code.