Filed is optional in ms-crm but showing mandatory in powerportal case creation! How? - microsoft-dynamics

Can anyone help me with the problem, field is showing mandatory in ms-crm powerportal but it is optional in ms-crm

Related

Display a variable in a Django form

I am trying to display a value from the database to a form. So if a user filled his email address, when he is connected he will see it in the email address form. I already did a post about this but I didn't get a lot of answer so I won't show my code this time but just ask you : Do you have an example of how to do it please ?
If someone need the answer to this question, check this post : How to display a variable in Django forms?
Now, stackoverflow bot think this should be a comment and not an answer so im just gonna paste some random code so he will leave me alone.
x = 1
if x == 1:
# indented four spaces
print("x is 1.")

Grab value after last slash in RegEx and ignore category slugs

I've URLs setup in following formats on old site:
blog/cat1/my-post-title
blog/my-post-title
blog/my-post-title/
blog/cat1/sub-cat1/my-post-title
and I'm trying to setup RegEx redirect for the following format:
articles/my-post-title
The category slugs are no longer required
So far, my poor attempt has been following, which you can see is flawed:
Rule 1:
blog\/(#?.*)\/(#?.*)\/(#?.*)
articles/$3
Rule 2:
blog\/(#?.*)\/(#?.*)
articles/$2
Rule 3:
blog\/(#?.*)
articles/$1
Can we setup a single rule and grab just the post slug that comes after the last slash and ignore all category slugs, if available?
Okay, I got it working with the following:
([^/]+\/?[blog/]{2}?\/)(.*?)([^/]+)/$
And to get the post slug:
articles/$3

Laravel 5.5 validation if checkbox is check and then validation on some field

I am new in Laravel I want to need some validation if I checked checkbox then in front of input field will validate Required|Numeric|min:1
Please Help.
As per below image
You are looking for required_if.
So, you could have the following rules in your Form Request or your Validator.
return [
'systolic_blood_pressure_high' => 'nullable|numeric|min:1|required_if:has_systolic_bp,on',
'systolic_blood_pressure_low' => 'nullable|numeric|min:1|required_if:has_systolic_bp,on',
];
Assuming you have a checkbox with name has_systolic_bp and it is checked, the fields systolic_blood_pressure_high and systolic_blood_pressure_low will be required.
You also need to mark them as nullable as by default Laravel will consider them as invalid because of the TrimStrings and ConvertEmptyStringsToNull middlewares.
For more information, check the documentation

Rails Validations - Reverse of Confirmation Validation

I want to be sure, two attributes don't have the same value with a validation in my Rails4 application. I know about confirmation validation but I need exactly the opposite of that.
Does Rails have this kind of validation?
You need to create a custom validation I think:
validate :check_attribute1_and_attribute2
def check_attribute1_and_attribute2
if attribute_1 == attribute_2
errors.add( :column_2, ' Value 2 cannot be similar to Value 1!')
end
end
Hope it helps :)
I had a similar need and wanted a simple solution. I thought this worked out pretty well in the end.
validates :applicant_id, exclusion: {
in: -> (reference_request) { [reference_request.reference_id] },
message: 'cannot also be a reference'
}

Can I change Django's auth_user.username field to be 100 chars long without breaking anything?

Before somebody marks this question as a duplicate of this question Can django's auth_user.username be varchar(75)? How could that be done? or other such questions on SO, please read this question. The question I linked to asks this question precisely but unfortunately the answers don't address the question that was asked.
Can I change the auth_user.username field to be 100 characters long by doing the following:
Run ALTER table in DB for the username field
Change the max_length here: username = models.CharField(_('username'), max_length=30, unique=True, help_text=_("Required. 30 characters or fewer. Letters, numbers and #/./+/-/_ characters"))
Would it break anything in Django if I were to do this?
That this will break when I update Django to a higher version is not a problem. I'm also not looking at writing other authentication methods.I just want to know if I would break anything if I were to do this.
You need to monkey-patch max-length in several places: model-field's description, form-field's description and max-length validators. Max-length validators are attached to form-fields as well as model-fields.
Here is a code snippet, which will patch everything:
https://gist.github.com/1143957 (tested with django 1.2 and 1.3)
Update:
Good news! Since django 1.5 you can override user model: Customizing the User model
There is no harm in doing that.
Just change the length in the model and in the database :)
Create a user profile model, add your very-long-username field there, and use it. of course this renders the genuine username field useless, but it is much better than hacking Django code, which will get you into trouble when you need to upgrade it.
For me, the code below works and is simple well.
from django.contrib.auth.models import AbstractUser
class MyUser(AbstractUser):
....
# your custom fields
MyUser._meta.get_field('username').max_length = 255 # or 100
after you can run your migration
If you change the database manually as well as the model accordingly then there should be no problem.
You can also change back otherwise, and I would say make a backup just in case but I'm not sure its even necessary
for future needs this is the best and easiest way i found out:
https://github.com/GoodCloud/django-longer-username
Another solution is to change your authentication code. When a new user signs up, they enter an email, you save this in the email field so you have it, and if their email is >30 characters, you shorten it before putting it into the user field. Then, change your login authentication for new logins.