Talent-Catalog / talentcatalog

https://tctalent.org
GNU Affero General Public License v3.0
10 stars 4 forks source link

Employer Access data issues #989

Closed cazcam34 closed 2 weeks ago

cazcam34 commented 3 months ago

Problems when adding new job - nothing loads for employer partners/job creators (non TBB).

Update: Issues due to data, employer ids not present causing errors. Also issue around employer access job creation, partners need to have a SF account link that is Partner (recruitment). Currently we have most accounts as 'Employer' (all minus two).

cazcam34 commented 3 months ago

After digging I found where this is happening. The new job component is checking for isEmployerPartner() through out the code. This relies on there being an employer associated with a partner assocaited with a logged in user. Currently in staging env there are two examples of this, Iress AU & Iress UK. So for those non TBB users they can create jobs. But any other job creator it doesn't work as employer is undefined. See code where this check occurs below.

Screen Shot 2024-05-15 at 3.12.11 pm.png

The New Job tab is shown for isJobCreator but we don't display the code in the app unless they are TBB user (SF link) or they are an employer partner & job creator (Iress AU & Iress UK). But there are lots of other job creators of different partners that then see the tab but don't see anything under.

cazcam34 commented 3 months ago

When I check Employer Partner? checkbox on Create/Update Partner it doesn't do anything UNLESS there is an SF link to the employer account. The form sends up this employerSfLink and that is used to get or create the employer on SF. I need to add some front end validation to make sure this is entered if the Employer partner checkbox is checked.

Screen Shot 2024-05-17 at 11.37.07 am.png

However we want to move away from adding SF links so it should just be a Search dropdown field searching for employer accounts (like the new joblink component searching for jobs on SF). We can then add an employer to a partner and that should make them an employer partner, removing the need for the checkbox AND sf link field.

cazcam34 commented 3 months ago

Probably need to chat with @camerojo when he is back

camerojo commented 3 months ago

I am not sure that this is a bug @cazcam34. It may be working as intended. The real question is are jobs being correctly created?

There are two different ways of creating a New Job - one of them displays a "Create Job" button and one doesn't.

The traditional way of creating a job is the TBB way - which requires a SFLink to be pasted in. Then the code has to look up the link and if it is a valid one, a Create Job button is displayed to complete the job creation.

The Employer access way of creating jobs is simpler - and doesn't require that extra step - so does need that extra "Create Job" stage.

camerojo commented 3 months ago

"But there are lots of other job creators of different partners that then see the tab but don't see anything under."

Note that there are only two types of partners who we support who can be job creators (ie those who see the New Job tab and who we know how to create a new job for). They are the ones you mention above: ie TBB and - recently - Employer Partners.

Source partners cannot create jobs (because they are not the ones who are located in the same country as employers). So the combination "source partner" and "job creator" on the partner creation is invalid - and should probably not been allowed to be entered on the front end when defining a partner.

We will be adding one more type of partner who can be a job creator: the Recruiter Partner. They are a destination partner who operates like an employment agency - replicating what TBB currently does in all our destinations.

camerojo commented 3 months ago

"I need to add some front end validation to make sure this is entered if the Employer partner checkbox is checked."

Yes - that definitely should be fixed.

"However we want to move away from adding SF links so it should just be a Search dropdown field searching for employer accounts (like the new joblink component searching for jobs on SF). We can then add an employer to a partner and that should make them an employer partner, removing the need for the checkbox AND sf link field."

Yes - but I don't think we are quite ready for this yet. There are currently employer accounts on SF which are not on the TC.

camerojo commented 3 months ago

So - given what I have noted above - do you think there is still a bug where new jobs are not being correctly created.

TBB and Employer partner users who are marked as job creators should both be able to create new jobs correctly - in their two different ways.

cazcam34 commented 2 months ago

@camerojo I understand the logic of two seperate kinds of job creation. However it appears that this 'bug' is related to bad data which has partners who are job creators but aren't assigned employer ids, therefore slip through the crack of not passing the isEmployerPartner check, however pass the isJobCreator check. So they see the New Job tab, but not see the content. Eg. in my local this was Iress Au, so when assigning users to this employer partner I was getting the error.

It will be resolved once start assigning employer ids to job creator partners, so it isn't a bug but it is causing an error and is makes it difficult for us to test the employer partner job creation (as @EhsanEhrari has found with issue #933). And then assigning an employer Id to a partner was a little unclear (as mentioned above) but now I know how to do it (checkbox + SF link required) it should be easier to test.

Just FYI ran some SQL to find any cases of this in prod & staging. In prod and staging there are two partners that are not source partners, are job creators but have no employer ids. See SQL below: SELECT id, name, source_partner, job_creator, employer_id FROM partner WHERE source_partner is false and job_creator is true and employer_id is null; They are Talent Lift & PSR Solutions. However it seems no users are assigned to these partners so it's irrelevant but maybe worth addressing.

Also you say that source partners shouldn't be able to create jobs, but BOSCO is a partner who is a source partner and a job creator...without an employer id. So prod & staging users assigned to them will also see the New Job tab but don't see content. I noted there were a few admin users assigned to BOSCO in prod.

I tested in staging by assigning myself to BOSCO and see below a screenshot of the 'bug' and how it appears.

Screen Shot 2024-05-31 at 12.15.19 pm.png

Totally hear you though, it's not really a bug but perhaps some way we can fix up data and/or make it easier to clearer how to assign employers to partners.... so adding validation that if employer partner checkbox is checked that SF link MUST be entered is really the bug here to fix?

cazcam34 commented 2 months ago

@camerojo I also found that once I created an employer partner, by checking 'Employer partner' checkbox and adding a 'Salesforce Account link' I started getting the following error (on local and staging) when it came to creating a job.

Screen Shot 2024-06-03 at 2.52.14 pm.png

Looking into the error (here) I found that the recruiter partner sf id must connect to an account with type 'Partner (recruitment)' and not 'Employer' like most of them. I found two examples of this in the SF sandbox and the same two are in prod. I imagine this has been discussed, that we will need employer accounts and partner accounts for employer partners?

Screen Shot 2024-06-03 at 3.12.48 pm.png Screen Shot 2024-06-03 at 2.55.09 pm.png
samschlicht commented 2 months ago

@cazcam34 @camerojo Just a note that I've edited the title and thread for this issue, since the issue re the SF links and 'Create Job' button have been addressed in #1045. There's been a bit of blending going on and I just want to make sure we don't double up on work!

camerojo commented 1 month ago

Note

Note that all these issues are all to do with correctly configuring a new partner on the TC (and Salesforce). That is an System Admin only task (the Partners tab of Settings is only displayed for System Admins). So validation is not as strict. This is not a show stopper for this release and doing testing with Iress. System admins just need to be careful when they configure new partners.

Note also that for normal users we want to get rid of Salesforce links - but, for the moment at least, it is OK for system admins to sometimes use salesforce links.

Some rules appear below. This issue will add some more validation - but care should still be taken when a system admin is setting up a new partner.

Extra Validation

camerojo commented 3 weeks ago

Related to the "Recruiter partner" Salesforce validation error, I updated Salesforce validation of the partner who created the job. I also added a more meaningful error message.

Partners who can create jobs must have Salesforce accounts of type Partner (recruitment), Employer or they must be TBB.

Applied change to Salesforce in both production and sandbox.

Screen Shot 2024-07-31 at 3 38 30 pm