-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
4Questions
-
6Replies
Replace Javascrip Button
I'm looking for the simplest way to proceed.
We have a Javascript button in Salesforce classic. It is on a custom object called Addresses. We have customers with multiple addresses they move back and forth to and from, so we list the addresses in this object. There is a button on the records that they users push to populate the addresse in that record as the current address in the account.
Here is the JS button code.
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/19.0/apex.js")}
var addr = "{!WV_Addresses__c.Id}";
var id = sforce.apex.execute("WV_AddressService","CopySingleAddress", {AddressID:addr});
window.alert("Address has been copied." );
This calls a Webservice program...
global class WV_AddressService {
WebService static void CopySingleAddress(ID AddressID){
WV_Addresses__c addr = [Select w.Worker_Profile__c, w.Type__c, w.SystemModstamp, w.Street__c, w.State__c, w.Postal_Code__c, w.OwnerId, w.Name, w.LastModifiedDate, w.LastModifiedById, w.IsDeleted, w.Id, w.Full_Address__c, w.Current__c, w.CreatedDate, w.CreatedById, w.Country__c, w.City__c, w.Active_On_Date__c, w.Mobile_Phone__c From WV_Addresses__c w WHERE Id = : AddressID];
WV_AddressController.CopyToAccount(addr);
}
}
Which calls the WV_AddressController.
Obviously the button does not work in Lightning, but the rest of the code works wonderfully and is a big timesaver for our users.All I ned to do is to replace the button that calls the Webservice with the 2 lines of script that the javascript button is currently calling. What is the easiest way to get than done?
Thanks!
We have a Javascript button in Salesforce classic. It is on a custom object called Addresses. We have customers with multiple addresses they move back and forth to and from, so we list the addresses in this object. There is a button on the records that they users push to populate the addresse in that record as the current address in the account.
Here is the JS button code.
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/19.0/apex.js")}
var addr = "{!WV_Addresses__c.Id}";
var id = sforce.apex.execute("WV_AddressService","CopySingleAddress", {AddressID:addr});
window.alert("Address has been copied." );
This calls a Webservice program...
global class WV_AddressService {
WebService static void CopySingleAddress(ID AddressID){
WV_Addresses__c addr = [Select w.Worker_Profile__c, w.Type__c, w.SystemModstamp, w.Street__c, w.State__c, w.Postal_Code__c, w.OwnerId, w.Name, w.LastModifiedDate, w.LastModifiedById, w.IsDeleted, w.Id, w.Full_Address__c, w.Current__c, w.CreatedDate, w.CreatedById, w.Country__c, w.City__c, w.Active_On_Date__c, w.Mobile_Phone__c From WV_Addresses__c w WHERE Id = : AddressID];
WV_AddressController.CopyToAccount(addr);
}
}
Which calls the WV_AddressController.
Obviously the button does not work in Lightning, but the rest of the code works wonderfully and is a big timesaver for our users.All I ned to do is to replace the button that calls the Webservice with the 2 lines of script that the javascript button is currently calling. What is the easiest way to get than done?
Thanks!
-
- Dave Wolfe 11
- October 09, 2018
- Like
- 0
- Continue reading or reply
Replace Javascript button with Apex Trigger
We currently have a javascript button that calls an apex class. As we move to Lightning we want to replace that button and the user would like (if possible) to simple have the apex method called automatically since we preform this task on every record in this custom object.
My thought was to call the existing apex from a new apex trigger fired after insert.
Here is the existing javascript code.

This script calls this apex class.

Which in turn calls this class.

I'm not reapply an apex developer and my initial attempts at the trigger failed.
Do I need to call the middle program at all if it is from a trigger? And how do I renmae the 'Candidate_Profile__c'id' to ID in the trigger as it was done in the javascript?
Or am I completely off base on how i am approaching this problem?
Thanks in advance.
My thought was to call the existing apex from a new apex trigger fired after insert.
Here is the existing javascript code.
This script calls this apex class.
Which in turn calls this class.
I'm not reapply an apex developer and my initial attempts at the trigger failed.
Do I need to call the middle program at all if it is from a trigger? And how do I renmae the 'Candidate_Profile__c'id' to ID in the trigger as it was done in the javascript?
Or am I completely off base on how i am approaching this problem?
Thanks in advance.
-
- Dave Wolfe 11
- July 18, 2018
- Like
- 0
- Continue reading or reply
Process Builder question about process created record
I have written a Process Builder for a custom transition object in our Salesforce instance. We use that object to put in status changes for our overseas workers (on field, vacation, medical leave, leave of absence, ect.).
The goal of the Process Builder is two fold.
a. When a worker transition is manually entered by a user ( worker going on vacation from 06/01/2018 - 06/14/2018) the system will automatically create a second transition record for the day after the first transition end date to put them back into 'On Field' status. I have this created 1 hour after the initial transition has been entered.
b. On the begin date of the transitions, change the worker status to whatever the transition status is (On Vacation).
Everything is working great in testing except one thing.....
The transition that is automatically created to put them back into 'On Field' status creates fine, but on the 'Begin Date' of that transition the worker status is not being updated. It IS updated on the begin date of the first status entered - which is the one that was entered initial by the user.
So in the example, on June 1st the worker is put into 'Vacation' status. But on June 15th, the worker status is NOT updated by the second transition.
Any ideas?
The goal of the Process Builder is two fold.
a. When a worker transition is manually entered by a user ( worker going on vacation from 06/01/2018 - 06/14/2018) the system will automatically create a second transition record for the day after the first transition end date to put them back into 'On Field' status. I have this created 1 hour after the initial transition has been entered.
b. On the begin date of the transitions, change the worker status to whatever the transition status is (On Vacation).
Everything is working great in testing except one thing.....
The transition that is automatically created to put them back into 'On Field' status creates fine, but on the 'Begin Date' of that transition the worker status is not being updated. It IS updated on the begin date of the first status entered - which is the one that was entered initial by the user.
So in the example, on June 1st the worker is put into 'Vacation' status. But on June 15th, the worker status is NOT updated by the second transition.
Any ideas?
-
- Dave Wolfe 11
- May 14, 2018
- Like
- 0
- Continue reading or reply
Validation rule triggered in error on insert from another object
I have created a validation rule on a field on a custom object that is part of a managed package. The validation rule simply prohibits the text length in the field from exceeding 30 characters. The actual text field the rule is on is a 255 character text field, but for our uses we need to limit the length to 30 characters. Since that field is part of a managed packaged I cannot change the field length. It works perfectly for standard inputs.
The issue arises when a record in the object is created from another custom object in the managed package. We are using Process Builder to populate the field that the validation rule is on with the text from a custom field in the originating object. It worked flawlessly until I created the validation rule. The text field in the originating object is only 30 characters long so it cannot exceed the rule limits. With the validation rule activated every time the originating object inserts a record the validation rule causes an error and prevents the insertion. And the Validation Rule fires before the Process Builder does so it cannot be the text length in the originating field causing the error.
Any ideas??
The issue arises when a record in the object is created from another custom object in the managed package. We are using Process Builder to populate the field that the validation rule is on with the text from a custom field in the originating object. It worked flawlessly until I created the validation rule. The text field in the originating object is only 30 characters long so it cannot exceed the rule limits. With the validation rule activated every time the originating object inserts a record the validation rule causes an error and prevents the insertion. And the Validation Rule fires before the Process Builder does so it cannot be the text length in the originating field causing the error.
Any ideas??
-
- Dave Wolfe 11
- July 27, 2017
- Like
- 0
- Continue reading or reply
Replace Javascrip Button
I'm looking for the simplest way to proceed.
We have a Javascript button in Salesforce classic. It is on a custom object called Addresses. We have customers with multiple addresses they move back and forth to and from, so we list the addresses in this object. There is a button on the records that they users push to populate the addresse in that record as the current address in the account.
Here is the JS button code.
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/19.0/apex.js")}
var addr = "{!WV_Addresses__c.Id}";
var id = sforce.apex.execute("WV_AddressService","CopySingleAddress", {AddressID:addr});
window.alert("Address has been copied." );
This calls a Webservice program...
global class WV_AddressService {
WebService static void CopySingleAddress(ID AddressID){
WV_Addresses__c addr = [Select w.Worker_Profile__c, w.Type__c, w.SystemModstamp, w.Street__c, w.State__c, w.Postal_Code__c, w.OwnerId, w.Name, w.LastModifiedDate, w.LastModifiedById, w.IsDeleted, w.Id, w.Full_Address__c, w.Current__c, w.CreatedDate, w.CreatedById, w.Country__c, w.City__c, w.Active_On_Date__c, w.Mobile_Phone__c From WV_Addresses__c w WHERE Id = : AddressID];
WV_AddressController.CopyToAccount(addr);
}
}
Which calls the WV_AddressController.
Obviously the button does not work in Lightning, but the rest of the code works wonderfully and is a big timesaver for our users.All I ned to do is to replace the button that calls the Webservice with the 2 lines of script that the javascript button is currently calling. What is the easiest way to get than done?
Thanks!
We have a Javascript button in Salesforce classic. It is on a custom object called Addresses. We have customers with multiple addresses they move back and forth to and from, so we list the addresses in this object. There is a button on the records that they users push to populate the addresse in that record as the current address in the account.
Here is the JS button code.
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/19.0/apex.js")}
var addr = "{!WV_Addresses__c.Id}";
var id = sforce.apex.execute("WV_AddressService","CopySingleAddress", {AddressID:addr});
window.alert("Address has been copied." );
This calls a Webservice program...
global class WV_AddressService {
WebService static void CopySingleAddress(ID AddressID){
WV_Addresses__c addr = [Select w.Worker_Profile__c, w.Type__c, w.SystemModstamp, w.Street__c, w.State__c, w.Postal_Code__c, w.OwnerId, w.Name, w.LastModifiedDate, w.LastModifiedById, w.IsDeleted, w.Id, w.Full_Address__c, w.Current__c, w.CreatedDate, w.CreatedById, w.Country__c, w.City__c, w.Active_On_Date__c, w.Mobile_Phone__c From WV_Addresses__c w WHERE Id = : AddressID];
WV_AddressController.CopyToAccount(addr);
}
}
Which calls the WV_AddressController.
Obviously the button does not work in Lightning, but the rest of the code works wonderfully and is a big timesaver for our users.All I ned to do is to replace the button that calls the Webservice with the 2 lines of script that the javascript button is currently calling. What is the easiest way to get than done?
Thanks!
- Dave Wolfe 11
- October 09, 2018
- Like
- 0
- Continue reading or reply
Replace Javascript button with Apex Trigger
We currently have a javascript button that calls an apex class. As we move to Lightning we want to replace that button and the user would like (if possible) to simple have the apex method called automatically since we preform this task on every record in this custom object.
My thought was to call the existing apex from a new apex trigger fired after insert.
Here is the existing javascript code.

This script calls this apex class.

Which in turn calls this class.

I'm not reapply an apex developer and my initial attempts at the trigger failed.
Do I need to call the middle program at all if it is from a trigger? And how do I renmae the 'Candidate_Profile__c'id' to ID in the trigger as it was done in the javascript?
Or am I completely off base on how i am approaching this problem?
Thanks in advance.
My thought was to call the existing apex from a new apex trigger fired after insert.
Here is the existing javascript code.
This script calls this apex class.
Which in turn calls this class.
I'm not reapply an apex developer and my initial attempts at the trigger failed.
Do I need to call the middle program at all if it is from a trigger? And how do I renmae the 'Candidate_Profile__c'id' to ID in the trigger as it was done in the javascript?
Or am I completely off base on how i am approaching this problem?
Thanks in advance.
- Dave Wolfe 11
- July 18, 2018
- Like
- 0
- Continue reading or reply
Validation rule triggered in error on insert from another object
I have created a validation rule on a field on a custom object that is part of a managed package. The validation rule simply prohibits the text length in the field from exceeding 30 characters. The actual text field the rule is on is a 255 character text field, but for our uses we need to limit the length to 30 characters. Since that field is part of a managed packaged I cannot change the field length. It works perfectly for standard inputs.
The issue arises when a record in the object is created from another custom object in the managed package. We are using Process Builder to populate the field that the validation rule is on with the text from a custom field in the originating object. It worked flawlessly until I created the validation rule. The text field in the originating object is only 30 characters long so it cannot exceed the rule limits. With the validation rule activated every time the originating object inserts a record the validation rule causes an error and prevents the insertion. And the Validation Rule fires before the Process Builder does so it cannot be the text length in the originating field causing the error.
Any ideas??
The issue arises when a record in the object is created from another custom object in the managed package. We are using Process Builder to populate the field that the validation rule is on with the text from a custom field in the originating object. It worked flawlessly until I created the validation rule. The text field in the originating object is only 30 characters long so it cannot exceed the rule limits. With the validation rule activated every time the originating object inserts a record the validation rule causes an error and prevents the insertion. And the Validation Rule fires before the Process Builder does so it cannot be the text length in the originating field causing the error.
Any ideas??
- Dave Wolfe 11
- July 27, 2017
- Like
- 0
- Continue reading or reply