How to randomize or shuffle Vendors for Job Offers and Availability Requests
This is an old version of the article. Please check the actual version in our new Knowledge Base.
Challenge description
We sometimes hear from our Clients that it is difficult to use all of the vendors and quite often - they complain about not being offered any jobs, despite meeting all the criteria.
The fact is that if you have comparable vendors, with similar competencies and rates, filtering and sorting them by the same criteria, will give the same results - with some names always on top, some others - down there, at the bottom. Some people will never have a chance to respond to job offers, because they never receive requests.
Proposed solution
One attempt to fix this is to shake, randomize or shuffle the database. Since we cannot change any vital details on the vendors' profiles, we need to add a 'chaos factor' to it, like a random number, which would change their order when sorted.
There will be sereval elements in this solution.
- Custom field of type Number in the scope of Vendors.
- Macro that would assign a random number in the field,
- Periodic Job to run the macro overnight.
- Job Offers / Availability Requests would use sorting by this Custom Field value, giving different results every day, despite the actual criteria for vendor selection unchanged. Vendor Selection Rules have to be set up.
Let's get to work
1. Adding a Custom Field is quite simple and has been described in this article
https://xtrf.userecho.com/knowledge-bases/6/articles/972-how-to-add-and-use-a-custom-field
Having added a field to vendors, we can manage them manually, however the whole point is to do it randomly and frequently.
2. A macro working in the scope of Vendors would change the number to a random value of natural numbers within any range, let's say 1-1000.
A very basic macro written in Groovy could look like this.
import com.radzisz.xtrf.model.partner.provider.Provider import com.radzisz.xtrf.utils.velocity.VelocityTagUtils class RandomizeVendorsMacro { def list def params VelocityTagUtils utils = new VelocityTagUtils() RandomizeVendorsMacro(list, params) { this.list = list this.params = params } def runMacro() { list.each { Provider provider -> provider.getCustomFields().setNumberField1(Math.random()*1000 as BigDecimal) } } } new RandomizeVendorsMacro(list, params).runMacro()
What is important about this particular example is that it runs on the very first Number-type custom field created within this scope. We can imagine making it more precise - to run on any chosen Custom Field.
It could be run manually, but again - the entire point is to have it done automatically by a Periodic Job "Macro subscription", executed overnight.
3. Setting up a Periodic Job is fairly easy. It could look like this.
4. Setting up Vendor Selection Rules for Job Offers / Availability Requests is as usual, up to your needs, but the key component would be sorting by Custom Field in question.
Here's an example for Classic Projects. You need to find the parameter called "Vendor, Custom Fields, yourcustomfieldname"
In case of Smart Projects, it will automatically suggest available Custom Fields, so it looks easier
That's it!
We hope you find it useful and effective.
Feel free to comment!
Customer support service by UserEcho