function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Guru 91Guru 91 

How to show and hide onclick java script button?

Hello Everyone,
I created Onclick java script button in quote to update quote version.
{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")} 

//declare the varaiable that will hold all the information 
var newRecords = []; 

var opp = new sforce.SObject("Quote"); 
opp.Id = '{!Quote.Id}'; 
opp.CBG_Check_to_Quote_Version__c = '1';
opp.CBG_Check_to_Version__c = '1';

if (confirm("Do you want to revise Quote?") == true)
 {
opp.CBG_Check_to_Quote_Version__c = '1';   
 txt = "You pressed OK!";
 
}

else 
{
opp.CBG_Check_to_Quote_Version__c = '0';
opp.CBG_Quote_Version__c = "  ";
txt = "You pressed Cancel!";



result = sforce.connection.update([opp]); 
window.location.reload(); 
opp.CBG_Check_to_Quote_Version__c = '0'; 
newRecords.push(opp); 
result = sforce.connection.update([opp]); 
window.location.reload();


This button is only visible if opportunity Brand = textile(Opportunity field).
so i created two separate record types with deferent page layout.
Now i created workflow to change record type.
Up to now working  well like whenever opportunity Brand = Phoenix and when i create New quote. I am able to see button in Quote detail page.
  User-added image            User-added image                               
Now if change opportunity Brannd = non Phoenix and if i update existing quote. I should not see the button button over there but button is there.---It is not working.

User-added image
User-added image

Please help me how to do it.
Best Answer chosen by Guru 91
Arpit Jain7Arpit Jain7
HI Guru,

In Text field set default value to "rev" in place of "rev00" then in your formula field if number field value is less then 10 then concatenate "00" in text field, If number is between 10 to 99 then concatenate "0" in text field and if number is greater then 99 then simply concatenate text field and number field.

Please let us know if this helps.

Thanks
Arpit

 

All Answers

Arpit Jain7Arpit Jain7
Hello,

Check once that you have assigned correct page layout related to record type for associated profiles. It looks like for the logged in user profile same page layout is assigned for both the record types hence it is showing the button in both case.

Please check and let me know for any issues.

Thanks
Arpit
Guru 91Guru 91
Hello Arpit,
Thank you
I assigned correctly, but is possible to change pagelayout for existing record based on parent field change.
Arpit Jain7Arpit Jain7
You need to write some WF rule to change record type on parent field change and page layout will then change based on record type.

 
Amit Tiwari 48Amit Tiwari 48
Tanks for the sharing this useful information.
Guru 91Guru 91
Thak you all i am to solve this problem.
 
Guru 91Guru 91
I have another small problem could you please give me some suggestions.
​1.for quote i am using sequence number like ( rev001)
2.whenever revision button clicked then number should increase like (rev002,rev003...)
3.to achieve this i created text field with default value "rev00"
4.i crated number field with default value as "0"
5. Now i crated formula field to concatenate text field with number field result like "re001"
6.now i crated work flow on onclick button condition to update number field.
7.now problem is like upto "re009" and if u update next time it becomes "rev0010"
8.But my requirement is like "rev010" ....."rev999"
Any idea how to do it.

 
Arpit Jain7Arpit Jain7
HI Guru,

In Text field set default value to "rev" in place of "rev00" then in your formula field if number field value is less then 10 then concatenate "00" in text field, If number is between 10 to 99 then concatenate "0" in text field and if number is greater then 99 then simply concatenate text field and number field.

Please let us know if this helps.

Thanks
Arpit

 
This was selected as the best answer