I have a choice field of type radio button. When the user selects the radio button I want to change the image depending up on the selected value. Below is the screen shot for the same Now when the User selects "Good" I want a calculated column to display Green and when they select "Bad" display Red. I was able to achieve the same with the below script.
Problem is when the question is big and have single Quotes like (') it is not working. Is there any better way where we can check in the if condition up to "GooD:","BAD:"? Please help me.
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
Start-SPAssignment -Global
$url = "http://santosh.test.com/sites/vendor"
$web = get-spweb $url
$fieldName="VendorRatingStatus"
if($field -ne $nul)
{
Write-Host $field.Title "Field already avilable in the site" -foregroundcolor red
}
$web.fields.add($fieldName, "Calculated", $true)
$SPField = $web.fields.getfield($fieldName)
$SPField.Required = $false
$SPField.OutputType="Number"
$SPField.Formula='=IF([Vendor]="GOOD:Vendor who deliver's a good Quality","<img src=http://santosh.test.com/sites/vendor/SiteCollectionImages/_t/GreenButton_png.jpg>",IF([Vendor]="BAD:Deliver's Bad Quality","<img src=http://santosh.test.com/sites/vendor/SiteCollectionImages/_t/RedButton_png.jpg>",IF(ISBLANK([Vendor]),"<img src=http://santosh.test.com/sites/vendor/SiteCollectionImages/_t/IntialButton_jpg.jpg>","")))'
$SPField.update()