Salesforce - Make all fields read-only - validation

I am trying to figure out the best way to make all fields in a custom object read only after a condition is met.
For example. There is a field called Status. If the status is equal to Closed, I want all fields on this custom object to be readonly i.e non editable.
What is the best way to do this? Validation rule, trigger, etc? I would really appreciate examples. Thanks

In short: With a workflow you could change the record type, for that record type you can assign a page layout which is read only.

Add a trigger to the custom object
Open custom object, click on the "Field Label" of one Custom Field, when it opens, create a new "Validation Rule" that checks the status and displays an error message

Related

Hide/Remove Text in the Column in CRM View "Items Available To Work on" for Queue Item entity

When a user opens the view "Items Available To Work on" for QueueItem entity, a related entity's column is showing some data in the view. I want to remove or hide that data when another column in the view has some specific data in it.
Here is the actual example which I need to achieve.
When the field "Case Type" has text "Revenue Collection" then hide text "Dummy Taxpayer" from the field "Taxpayer". Both fields are showing from related entity Case in this QueueItem view.
I have checked the following possibilities but these are not working.
1- RetrieveMultiple message cannot be used with the QueueItem entity.
2- Tried with entity "SavedQuery" on RetrieveMultiple, but that is giving FetchXML of the view. We cannot change the result of the FetchXML dynamically here also.
3- In the properties of the column "Taxpayer" in the view, we do not have the option to run a JavaScript as my CRM version is 2016. This feature is available in Dynamics 365.
So, there is no supported way to achieve this as per my understanding. Any help/suggestion is appreciated on this issue
In Grid,
You cannot Hide/show column dynamically depending on your condition. Rather you can enable/disable field so that users cannot edit field based on Condition.
Please find Link Article as Example.
This is more of a data captured problem rather than data hide/show problem.
When the case type is "Revenue Collection", the value of the "Tax payer" should be null. Then this problem is solved in grid/view or form and everywhere.

admin on rest in create form - Generated the TextInput by loop. If I type anything in one text-box, it is reflecting in all other generated text-box

I created the TextInput by loop. If I type anything in one text-box, it is reflecting in all other textbox's as well. How to prevent this reflecting one textbox value into others textbox's automatically.
You should set it's source property. But it's always best to show an example of your problem in a codesandbox.

Access 2016 Form Control Validation Rule Not Firing

I have a simple unbound access 2016 form. On the form, I have several controls including text and combo boxes. On the first text box control I would like to require a data value (underlying table field data type is short text).
I have set the Validation Rule property for the control in the property sheet to "Is Not Null" and added an appropriate validation text message.
For an unknown reason I have not been able to get this validation rule to ever fire. I have cleared the validation rule on the table to make sure it wasn't interfering, however, no luck.
It's like the validation check is not happening when focus leaves the control. There is no other event procedure that has been written that would interfere either.
Thanks for the help.
You can give the control a default value, then
Form_load()
Yourcontrol.setfocus
Sendkeys "{DEL}"
The requirement was to validate the control for a missing value using the validation rule when the control lost focus (ie user tabbed out of text box without ever entering a value). I wanted the user to get immediate feedback that they needed to provide a value for the given control.
As Rene pointed out in the comments, the validation rule does not fire unless there has been a value change.
The Sendkeys solution has issues, I only use Sendkeys as a last resort.
The solution in this case was to put the validation test in the Control_OnExit event handler. The user gets immediate feedback as desired and does not wait until the record is submitted.
One further note that could easily be missed; in an unbound form, the before_update event will never fire.

In EWL, can you alter a form item’s contents after a failed validation?

On an EWF page, is it possible to alter the content of a form item during validation (when a validation fails)? For an example: say you have a text box that you want to be spell checked before it gets entered into the database. You use the modification's GetSpellCheckedWordTextFormItem to get the form item, and you want to replace what the user enters ("teh") with a likely suggestion ("the") when the validation fails to find a word it knows. Then the user sees the validation error ("Is this the word you meant?"), looks at it and corrects it or not, then re-submits.
Is there a way to do that? If so, how?
The specific answer to your question is no, you can't alter any form values if validation fails. To implement this, you'd need to let the validation succeed and let the data get modified. As part of the validation/modification, you could set a piece of page state that causes the next loadData pass to display the "is this the word you meant?" message near the spell-checked form item. Of course, you would have already saved the corrected text.
Alternatively, you could use PostBack.CreateIntermediate to make a post-back that only runs the spell-check, puts the corrected text in page state, and displays "is this the word you meant?". You'd set that post-back to fire when the user tabs out of the text box, and then you'd have the main post-back grab the corrected text from page state and save it in the database or other durable storage.

Ajax Autocomplete field: display one value, but use another?

I've got an autocompleter in a CakePHP app that provides a dropdown list of neighborhoods to attach to a place. I'm pulling from a table 'neighborhoods' with name and id fields. I want the user to see the name of the neighborhood, and I want the app to see the id of the neighborhood and insert it into the places table. How can I make this happen?
Another way of doing this would be to storing the id. Then when a user presses submit you replace the input field's value with your stored value.
assign the correct (hidden) value to a hidden input field
This type of functionality is normally achieved with a combobox, which is like an autocomplete, with an underlying select elememt, see here

Resources