-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add scripts for creating a community user and adding profiles to community member groups #10
Conversation
@jlantz this is definitely not ready for review since it's still messy and more a proof of concept right now, but could use your input on a couple of things. Over this past weekend, I discovered that since a template is being used to create the community, I'm pretty sure I cannot load unpackaged Network Member Group metadata. Basically, this means I cannot give access to the community to the correct Permission Sets/Profiles. As far as I can tell there are two ways to do this:
Thanks for any help! |
…ttps://github.com/SFDO-Community/TractionThrive into feature/jjoseph/automate_community_contact_creation
Add Python Script to Automate Id pulling from SQL file
Re-factor to combine two for loops
…task and flow to run transform script
… authority to network memeber group; add a new task to reset the nmg load file to it's original state; switch automatic user creation to medical staff
…ttps://github.com/SFDO-Community/TractionThrive into feature/jjoseph/automate_community_contact_creation
@sgovindankutty this is ready for review whenever you get a chance outside of the code review here are some good steps to test:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good from a CumulusCI perspective. Would still be good to get a review from an Apex dev
localesidkey = 'en_US', | ||
Contactid = newContact.Id, | ||
timezonesidkey = 'Asia/Dubai', | ||
username = newContact.email, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Org-scoped username uniqueness should in theory be on - any chance you've built two orgs with the same value here at the same time just to confirm?
@@ -0,0 +1,47 @@ | |||
from cumulusci.tasks.salesforce import BaseSalesforceApiTask | |||
|
|||
class NgmTransForm(BaseSalesforceApiTask): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to be a BaseSalesforceApiTask
; it doesn't talk to the API. Looks like BaseTask
should be fine here.
return line[index1:index2] | ||
|
||
def createInsertLine(id, networkId, count): | ||
insertLine = "INSERT INTO \"NetworkMemberGroup\" VALUES(" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An fstring could clean this up nicely to make it clearer what the method intends to do.
if 'Customer Community - Health Authority' in line: | ||
ids.append(getId(line=line)) | ||
if '"Network" VALUES' in line: | ||
networkId.append(getId(line=line)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could do something here like
lines_to_look_for = ['Customer Community - Medical Staff', 'Customer Community - Hospital Administrator', 'Customer Community - Health Authority']
if any(search in line for search in lines_to_look_for):
ids.append(getId(line=line))
and just handle the network id separately.
@@ -0,0 +1,13 @@ | |||
from cumulusci.tasks.salesforce import BaseSalesforceApiTask | |||
|
|||
class NgmSqlReset(BaseSalesforceApiTask): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also be a BaseTask
.
loadFile.write( createInsertLine(id = id, networkId = networkId[0], count = count )) | ||
loadFile.write('\n') | ||
|
||
loadFile.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker, but I'm wondering if this could be achieved more expeditiously just by talking to the REST API rather than doing a bulk extract/transform/load. Can't say as I've tried to load this particular object before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidmreed yeah that would have been ideal but unfortunately you cannot manipulate Network Member Group
through Rest API. You can only use SOAP or bulk. If there is a SOAP way that is better I'm all ears!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is... Nuts. I had no idea there were such objects. Thanks for the enlightenment. Bulk it is!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidmreed Yeah same here. I've learned so much about communities in the last week. It's a whole other world of metadata!
networkId.append(getId(line=line)) | ||
|
||
loadFile.write('\n') | ||
for id in ids: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a nice function called "enumerate" that allows you to count items at the same time. It would look like:
for count, id in enumerate(ids, 1): ...
# profile you'd like to add a network member group for | ||
if 'Customer Community - Medical Staff' in line: | ||
ids.append(getId(line=line)) | ||
if 'Customer Community - Hospital Administrator' in line: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might use elif here?
# Replace 'Customer Community - Medical Staff' with the permission set or | ||
# profile you'd like to add a network member group for | ||
if 'Customer Community - Medical Staff' in line: | ||
ids.append(getId(line=line)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might not need to use a keyword argument syntax for a single-argument function.
mapping: datasets/mapping-nmg-load.yml | ||
sql_path: datasets/nmg-load.sql | ||
4: | ||
task: reset_nmg_sql |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something seems a bit weird about modifying a file and then resetting it. Can't you just make a brand new file and then delete or ignore it?
Why does the repository need to contain datasets/nmg-load.sql at all, if it is just a copy of the template? Instead of appending to it couldn't you read the template, write it, and then continue adding to it? I might miss something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way feels a bit risky because if the flow fails (which they often do) then the file could be in a weird state and you'd append to a file in the wrong state.
@prescod @davidmreed @jlantz Thanks for all the feedback! Since none are blockers I'm gonna recommend this for merge, but I've captured the suggestions in #73 so these scripts can be improved down the line. |
@camgood-trac the release engineering team at Salesforce.org has approved this org-setup related PR with non-blocker suggestions that I've captured in issue #73. Feel free to review and/or merge whenever you're ready :-) |
Critical Changes
Changes
Issues Closed