+1
Under review

Number of jobs: Zero ("0" versus " - ")

Seyma Albarino 5 years ago in Home Portal / Smart Projects updated by mark 5 years ago 11

We've noticed that when filtering views to include the number of jobs a vendor has completed, there's an inconsistency in terms of how "zero" jobs are represented in the "Number of Jobs" column. We see "0" for some vendors and " - " for others. 


I can't understand why some vendors would have one shown versus the other. Do they indicate different things?

On a related note, it's very inconvenient to have "zero" jobs marked as " - " instead of 0. This makes it impossible to filter for vendors who haven't done any jobs yet (instead, we have to include them in a larger list of vendors and then sort the column by number of jobs to find those who haven't done any).

Image 1149


Image 1150

Answer

Answer
Under review

Null is on those, who never had jobs. 

Zero is on those, who had jobs, but they were taken away from them. 

The numbers are set by a periodic job running in the background, so anyone with 0 had another number for a while, which was then 'zeroed'.

Answer
Under review

Null is on those, who never had jobs. 

Zero is on those, who had jobs, but they were taken away from them. 

The numbers are set by a periodic job running in the background, so anyone with 0 had another number for a while, which was then 'zeroed'.

+1

Is it possible to create a macro or a periodic job to remove the nulls and replace them with zeros? We find it frustrating that we can't filter or sort by null sets. Or allow for a filter that has null sets as an option?

Hi Mark,

I've reported this as an issue to our Product Team. 

Meanwhile, here's a simple macro that will set this value to 0 in case it it null:

list.each {

provider ->

if(!provider.getNumberOfActivities()) provider.setNumberOfActivities(0)

}

Best,

Bartosz

Great. Thanks Bartosz. So this macro if run, will convert null fields to zeros, just for that one field. Right? And it's set on the Vendor class I assume?

And actually, what are the other settings that I need to input? It's not working for me. Giving me an error.

Just an FYI, I've tried this with many settings, and I can't get this to work. :(

Hi Mark,

Sorry for not being clear enough. 

To install this macro you need to: 

1. Go to Settings (gear icon on the top-right),

2. Go to Integration and then Macros,

3. Click on Add,

4. Set "Class name" to Provider,

5. Set whatever name you'd like, 

6. (important bit that was probably causing an error) tick Macro Modifies Model Data and if you wish to run it periodically, don't forget about Macro Generates Output

7. Set "Script Language" to Groovy

8. Paste the code in the "Expression" box.

After that, go to Providers module. You can select all providers as this macro will only change this one field and only if it is null. 

Great! Thanks. It works! Two comments.

1) I don't see "Provider" as a class name option. I see "Vendor". Probably just part of my localization.

2) While the macro works, I am getting a weird code output after the job runs. I get a white screen with text similar to this:

[2905-com.radzisz.xtrf.model.partner.provider.Provider, 3327-com.radzisz.xtrf.model.partner.provider.Provider]

But even after I see this odd text, the nulls are converted to zeros, so this isn't a huge deal.

Thanks again!

+1

Hi Mark,

You guessed it, Vendor/Provider depends on the English dialect you're using in your system. 

To get rid of the "weird part" you can use this version instead:

list.each {

provider ->

if(!provider.getNumberOfActivities()) provider.setNumberOfActivities(0)

}

return ""


Works exactly the same but won't display anything afterwards. This change doesn't affect any aspect of running this macro and you will still be redirected to the white page after running it, just without any text on it. If you wish not to be redirected, please untick "Macro generates output", but please remember that turning that tick off will prevent you from running this macro as a periodic job.


Glad I could help!

Please let me know if you'll need further assistance.

This is great. Thanks so much!

+1

I'm glad it helped!

I can see that fix is already in place, currently waiting for the final revision from Quality Assurance, so it seems that 8.3 (8.4 if anything goes wrong here) might not need this macro-patch anymore. 

Best,

B.

That's so helpful. Thanks.