You need to sign in to do that
Don't have an account?

remove asterisk from mobile number field
Hi
I having a custom objectProfile which has got mobile number field , Datatype=phone
Two things happen when the page loads
a) I append an ID to the URL so I will fetch all values into the respective controls
b) If mobile phone exists then it should be masked , for ex: *************
If mobile number is changed then it stores mobile number sobject field correctly without asterisk.
But if mobile number is not changed then it stores asterisk in sobject field .
any help will be rewarded.
Here is my code:
Thanks
JohnD
I having a custom objectProfile which has got mobile number field , Datatype=phone
Two things happen when the page loads
a) I append an ID to the URL so I will fetch all values into the respective controls
b) If mobile phone exists then it should be masked , for ex: *************
If mobile number is changed then it stores mobile number sobject field correctly without asterisk.
But if mobile number is not changed then it stores asterisk in sobject field .
any help will be rewarded.
Here is my code:
public class PrefCenterCTRL { public String fanMobile { get; set; } //masked value public PrefCenterCTRL() { encryptedfanID=ApexPages.currentpage().getparameters().get('id'); if(String.isBlank(encryptedfanID)) { ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Invalid Id.'); ApexPages.addMessage(myMsg); return; } else { try { fetchfanvalues(); } catch(System.QueryException ex){ Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'No Record')); } } } public void fetchfanvalues() { fan = new fan__c(); fan=[SELECT id, Mobile_Phone__c, FROM fan__c WHERE Encrypted_ID__c=:encryptedfanID]; if(!string.isBlank(fan.Mobile_Phone__c)) { fan_Mobile=fan.Mobile_Phone__c; fanMobile=maskPhone(fan.Mobile_Phone__c); } }} //save the values public void SaveValues() { if (fan != NULL) { if (fanMobile.equals(maskPhone(fanMobile))) { fan.Mobile_Phone__c=fan_Mobile; } else { fan.Mobile_Phone__c=string.valueOf(fanMobile); } public PageReference btn_profile_saveChanges() { SaveValues(); return null; } } <apex:page controller="PrefCenterCTRL" docType="html-5.0"> <apex:form> <apex:inputText value="{!fanMobile}" styleClass="form-control"/> <apex:commandButton value="Save" action="{!btn_profile_saveChanges}/> <apex:form> </apex:page>
Thanks
JohnD
How you know that your Contact values are changed
Initially when page loads, mobilephone value is masked. so in controller's constructor I am capturing the original value(I mean unmasked value) into fan_Mobile which is then passed to sobject.mobile_phone__c assuming the user doesnt make changes and hits save button.
thanks
John D
Now if the user changes the mobile number then the changed value shud be reflected in sobject but it is not happening
thanks
JohnD
I sloved your problem in my org but i used Account object in my vf page Run the code and and Let me know if this is helpful
Marked as best answer if this was helpful
Thank you
Avaneesh Singh
if your problem is sloved then mark as best answer else Let me know the issue ??
Thank you
Avaneesh Singh
In my custom object email is an required field, so update throws error.
any other way wherein I can use inputhidden field in vf page and capture that value in controller?
thanks
JohnD
Send me your code and mark that line where it throw error ...Let me check once
Thank you
Avaneesh Singh