Import Failure - Role With Id Does Not Exist - dynamics-crm-2011

I am getting an import error in a specific environment with a managed CRM 2011 solution. The solution has been imported before into many other environments, but the one in particular where it is failing is throwing the following error:
Dependency Calculation
role With Id = 9e2d2d9b-645f-409f-b31d-3a9c39fcc340 Does Not Exist
I am a bit confused about this. I searched within the solution XML and was not able to find any reference to this particular GUID of 9e2d2d9b-645f-409f-b31d-3a9c39fcc340. I cannot really find it in SQL either, just wandering through the different tables, but perhaps I do not know exactly where to look there.
I have tried importing the solution multiple times. As a desperation effort, I tried renaming all of the security roles in the destination environment prior to importing, but this did not help.
Where is this reference to a security role actually stored? Is this something that is supposed to be within my solution--which my existing CRM deployment is expecting me to import?
How do I fix the problem so that I am able to import this solution?

This is the code we used to fix the issue. We had to run two different scripts. Script A we had to run a total of four times. Run it once, attempt the import, and then consult the log to find the role that is causing the problem--if you receive another error for another role.
To run script A, you must use a valid RoleTemplateId from your database. We just picked a random one. It should not matter precisely which one you use, because you will erase that data element with script B.
After all of the roles are fixed, we got a different error (complaining something about the RoleTemplateId was already related to a role), and had to run script B. That removes the RoleTemplateId from multiple different roles and sets it to NULL.
Script A:
insert into RoleBaseIds(RoleId)
values ('WXYZ74FA-7EA3-452B-ACDD-A491E6821234')
insert into RoleBase(RoleId
,RoleTemplateId
,OrganizationId
,Name
,BusinessUnitId
,CreatedOn
,ModifiedOn
,CreatedBy
)
values ('WXYZ74FA-7EA3-452B-ACDD-A491E6821234'
,'ABCD89FF-7C35-4D69-9900-999C3F605678'
,(select organizationid from Organization)
,'ROLE IMPORT FIX'
,(select BusinessUnitID from BusinessUnit where ParentBusinessUnitId is null)
,GETDATE()
,GETDATE()
,null
)
Script B:
update RoleBase
set RoleTemplateId = NULL
where RoleTemplateID='ABCD89FF-7C35-4D69-9900-999C3F605678'

Perfect solution, worked for me! My only comment would be the error in Script B: it shouldn't clear the template IDs of all roles for the given template, only the template ID of the newly created "fix" role, as follows:
update RoleBase
set RoleTemplateId = NULL
where RoleID='WXYZ74FA-7EA3-452B-ACDD-A491E6821234'
I would've gladly put this in a comment to the answer, but not enough rep as of now.

Related

Database References on Deploy

I have (several) database project in a solution. In one I have a referesnce to a dacpac (this is ACTUALLY a copy of one of the main databases as we take a SQL snapshot at end of day and some code needs to reference this (DBANME_Daily) rather that DBNAME).
now this builds correctly, the code with SELECT * FROM DBNAME_DAILY.schema.table all compiles and builds with no error.
ON deployment however I get the unresolved reference to DBNAME_DAILY.schema.table
You want to add a dacpac for that database as a reference, using variables for the database. Should be different database, different names. You'd then use that variable in your code and you'd pass in the variable name for your build/publish tasks depending on the environment.
This is a little older article, but still pretty accurate:
http://schottsql.com/2012/10/31/ssdt-external-database-references/
You can tweak that a little bit using a variable for the database name. When I wrote this, it was mostly just a different database with the same name across environments. For your case, you'd just use the DB variable. Then replace your "DBName.schema." with "[$DBNameVariable].schema." (or something similar)
Sorted, my mistake was the dacpac reference would only allow the project to BUILD. For deployment the database DBNAME_DAILY MUST EXIST.
Lesson Learnt.

Copy ManyToMany Value

I am currently trying to copy a many-to-many-field from one model to another but running into a bit of trouble. I have been able to create the model fine with a many-to-many-field with a ModelMultipleChoiceField, and the model saves the way I want it to. When I try to copy it to another model, I don't get an error, but nothing happens. Here is the code that I have tried:
author = Author.objects.create(author=self.author)
author = Author.objects.all()[0]
book = entry.approvers.all()
author.pk = None
author.readers.add(*self.readers.all())
I researched this all am and see that M2M models can be tricky. I've tried several variations of the code above and nothing works. I worked my way through several must be an instance errors this am, and that's how I discovered the author = Author.objects.all()[0] command. I no longer get an error but my many-to-many values are not being copied over to another model either. Thanks for any help.
I found this reference on SO and it seems to be what would help me but I tried it and it doesn't work. I am using generic class based views which is probably what is causing me a bit of additional grief.
Class Based Views (CBV), CreateView and request.user with a many-to-many relation
From the example, I used this template for my code but to no avail.
I get needs to have a value for field "id" before this many-to-many relationship can be used.
I just found this reference, Django. Create object ManyToManyField error
It works, and I can then use the following command to post one of the M2M values, but how can I do this without hard coding the pk?
book.reader.add('1')
The above works, but when I try something like
book.reader.add(*self.readers.all())
I've researched this further and this...
author = Author.objects.create(author=self.author)
Plus this alone works...
book.reader.add('1')
Just need to figure out how to replace '1' with a variable name.
After more investigation this may be related to the following issue?
Django: IntegrityError during Many To Many add()
It would seem maybe there is some kind of bug with the bulk_create? The individual add with a hardcoded number works just fine. When I try with the (*self.readers.all()) I don't receive an error message but the manytomany reference is not copied over to the over table. I've seen several articles that say that the commands I'm using work just fine, but perhaps it's for something other than PostgreSQL.
Thanks for any thoughts.
As a newbie, I was doing this work in SAVE. Once I moved it to post_save, the following format worked as expected...
#receiver(post_save, sender='Test.Book')
def post_save(sender,instance, **kwargs):
author = book.objects.create(subject=instance.book)
author.approvers.add(*instance.approvers.all())
As a newbie, I was doing this work by overriding SAVE in my model instead of doing this work in a post_save signal. Changing my approach fixed my issue. The code associated with my correct approach is..
#receiver(post_save,sender='Test.Book')
def post_save(sender,instance,**kwargs):
author = book.objects.create(subject=instance.book)
author.approvers.add(*instance.approvers.all())

custom type/provider case insensitive title

Is there anyway to normalize the title value through a munge call or something similiar?
I have a custom type/provider that manages local group membership on Windows machines (we needed more granularity over group membership, than just inside the user/group types.
group_member{"Group => Member":
ensure=>present,
}
group_member{"Group => DOMAIN\Member":
ensure=>present,
}
resources{'group_member':
purge =>true,
}
In general, when everything is consistent everything works great. The issue comes in that windows/active directory are not case sensitive. Therefore, when self.instances gets called, It generates a resource Group_member["Users => DOMAIN\SomeGroup"], but in our puppet manifest, Users is hardcoded, DOMAIN comes from a fact, and SomeGroup comes from a hiera value.
We've been fighting with the case sensitivity of puppet for about 5 years on this, and most of our administrators have gotten used to ensuring case matches between domain and yaml configurations.
Now, we have a new problem... somehow DOMAIN is messing up. On a new testing domain, the NETBIOS name is lowercase. The fact we had returning DOMAIN still returns uppercase, but Windows ADSI is returning a lowercase form. This wouldn't be an issue if we wern't using resources{'group_member': purge=>true}, but now in this test environment the groups get added (through their respective .pp files) and removed (through resources{'group_member': purge=>true}}) every puppet run.
Ideally i'd like to just normalize everything to lowercase in self.instances and in all of our .pp files, but we have 400 puppet modules and we use group_member 120 times, managed by quite a few different teams. It would be significantly easier if I could just munge the title metaparameter.
Any suggestions?
So, the way i'm handling this is to rename the existing type/provider and wrapping it in a define type that downcase's the title.

How do you delete or rename content parts in Orchard?

I gave a content part a wrong name and I want to rename it. I tried renaming the classes and all calls of it in the solution to no avail. I even tried deleting entries from the ShellFeatures table and the table generated by Migrations itself, but that just made things worse. Now the whole module's features aren't being recognized. Anyone tried this before?
I know this is an old question but I just had to tackle this and this is the first result I landed on from Google.
You can delete the ContentPart and add it again using migrations for example:
public int UpdateFrom3() {
// remove the AccreditationsPart part cleanly
ContentDefinitionManager.DeletePartDefinition(typeof (AccreditationsPart).Name);
enter code here
// re-add the AccreditationsPart again
ContentDefinitionManager.AlterPartDefinition(typeof (AccreditationsPart).Name,
cfg = > cfg
.Attachable()
.WithDescription("Adds a row of configurable accreditations to the content type"));
return 4;
}
You would need to customise the update numbers to fit your current migrations.cs and also change the AlterPartDefinition to match whatever you want it to be.
WARNING: This is only intended for fixing problems that you catch straight away. When you delete the part in the first section of the migration you will lose any associated data. If you already have the code running in production then you will have to use a different approach.

Subsonic ActiveRecord

I am trying to get Subsonic(3.0.0.4) to work(.Net 3.5 - VS2010), simple install that looks at the Northwind database using ActiveRecord. I used the 5 minute demo from http://subsonicproject.com/docs/The_5_Minute_Demo. I added the reference to the dll, un-blocked the T4 templates that I downloaded, changed the Settings.ttinclude to point to the northwind database in 3 places as per video. Dragged the T4 templates (as per video) to my Models folder in VS2010.
If I compile I keep on getting "Type or namespace name 'something' could not be found" There are 13 error (same amount as the amount of tables in the DB..) so I am guessing that there must be some command that turns every table into a class, but where? I right-clicked on ActiveRecord.tt and Context.tt and selected "Run custom tool" with no success.
Any help, I follow this demo to the letter and still get the error. Any help.. please?
Ok, I do not know why but after I added Structs.tt it compiled fine. I still could not get the foreach in the view to work, the error was: foreach statement cannot operate on variables of type 'object' because 'object' does not contain a public definition for 'GetEnumerator'
I could see out of the corner of Rob's video that it did not inherit from System.Web.Mvc.ViewPage and figured out that it should be System.Web.Mvc.ViewPage>
Sometimes clever people(Like Rob) cannot think for proper dummies(like me) Such is life?

Resources