Hi,
Your code will give error if the website url field value is null because you are checking below line as the attribute is null, so null.equals will fail for the below line
if (entity.Attributes["websiteurl"].Equals(web1) )
Try with the below code it will work when the record is crating.
If you want update the Web site Url field on record update also , you need to fetch the account entity website attribute field value
Because if you did not modify the field value at the time record updation , then you can not get field value direct from entity.
if (entity.Attributes.Contains("websiteurl"))
{
if (entity.Attributes["websiteurl"].ToString().ToLower() == "google.com")
{
entity.Attributes["websiteurl"] = "yahoo.com";
}
}
else
{
entity.Attributes["websiteurl"] = "google.com";
}
Regards,
Priya