-
ChatterFeed
-
101Best Answers
-
0Likes Received
-
5Likes Given
-
10Questions
-
1056Replies
Authenticate then open External URL from within Salesforce
In my mind what I need to do is simple, but everything I seem to find leads me down a path of complex development. Maybe I'm searching on the wrong terms.
Here is what I'm trying to do.
Use case - User needs to click a button(action, etc.) in a record to open to an externally hosted site to perform a task that ties to the SF record they're working in. On click, it would automatically authenticate to the site, pass initial values, and then open the web page in an iframe (preferable), or in a new browser window/tab with the initial values populated.
Basic logic - (at least in JSON)
3. Display that session - bearer token in the header, sessionid appended to the end of a static external URL
The primary issue for me is the structure of this. Writing the code itself isn't really an issue. It's where to put it all and bring it all together.
I had thought this could all be in done in a VF page, but that doesn't seem to be the case. Some people recommend using Canvas, but that seems to be way over the top.
Any help, guidance is greatly appreciated.
- Rudabaugh
- June 10, 2020
- Like
- 0
- Continue reading or reply
Open existing Lightning Web Component using Visual Studio Code app?
I did install Salesforce in Visual Studio Code but not sure how to use it once it's installed
Any tips are appreciated.
Most of my old experience was with Apex/VF and Eclipse IDE.
- debra
- January 29, 2020
- Like
- 0
- Continue reading or reply
how to get the account related quotes into an lightning component
I want to create a lightning component where i need to pass the current account Id to the component and display all the quotes that are related to the account id.
- john miir
- January 29, 2020
- Like
- 0
- Continue reading or reply
Visualforce Page for Filtering Reports
I'm trying to embed a Visualforce Page onto my home page that allows users to select a report and filter it right there.
When running I seem to be getting the following error:
caused by: System.NullPointerException: Attempt to de-reference a null object
Class.AnalyticsController.getSelectedFilters: line 69, column 1
Class.AnalyticsController.getChartFilter: line 64, column 1
Can anyone identify what's causing this issue? I notice this code was written for API Ver 29, while I'm on 48.
Visualforce Page:
<apex:page controller="AnalyticsController"> <style> label { font-weight: bold; } #filters { overflow: hidden; width: 100% } #filterBox { float: left; align: center; padding: 5px 5px 5px 0px; } </style> <apex:form > <apex:outputLabel value="Select Report"/> <apex:selectList value="{!reportId}" multiselect="false" size="1"> <apex:selectOptions value="{!availableReports}"/> </apex:selectList> <apex:commandButton action="{!getReportInfo}" value="Get Report Filters" reRender="report"/><br/> <apex:outputPanel id="report" layout="block"> <apex:outputPanel rendered="{!reportId != null}"> <div id="filters"> <apex:repeat value="{!availableColumnFilters}" var="colFilter"> <div id="filterBox"> <apex:outputLabel >{!colFilter.label}</apex:outputLabel><br/> <apex:selectList value="{!colFilter.operator}" size="1" multiselect="false" style="width: 100px;"> <apex:selectOption itemLabel="--None--" itemValue=""/> <apex:selectOptions value="{!availableDataTypeFilterOperators[colFilter.dataType]}"/> </apex:selectList> <apex:inputText value="{!colFilter.value}"/> </div> </apex:repeat> </div> <apex:commandButton value="Get Chart with Filters" reRender="chart"/><br/> <apex:outputPanel layout="block" id="chart"> <analytics:reportChart reportId="{!reportId}" filter="{!chartFilter}"/> </apex:outputPanel> </apex:outputPanel> </apex:outputPanel> </apex:form> </apex:page>
Controller:
public with sharing class AnalyticsController{ public List<SelectOption> availableReports { get; set; } public Id reportId { get; set; } public Map<String, List<SelectOption>> availableDataTypeFilterOperators { get; set; } public List<ColumnFilter> availableColumnFilters { get; set; } public AnalyticsController() { availableReports = retrieveAvailableReports(); availableDataTypeFilterOperators = retrieveAvailableDataTypeFilterOperators(); } public List<SelectOption> retrieveAvailableReports() { List<SelectOption> reptOpts = new List<SelectOption>(); for (Report r : [ Select Id, Name From Report Where Format In ('Summary','Matrix') Order By Name ]) { reptOpts.add(new SelectOption(r.Id, r.Name)); } return reptOpts; } public Map<String, List<SelectOption>> retrieveAvailableDataTypeFilterOperators() { Map<String, List<SelectOption>> dataTypeFilterOpts = new Map<String, List<SelectOption>>(); Map<String, List<Reports.FilterOperator>> filterOperatorMap = Reports.ReportManager.getDataTypeFilterOperatorMap(); for (String dataType : filterOperatorMap.keySet()) { List<SelectOption> operators = new List<SelectOption>(); // Append _DATA to match ColumnDataType from ReportTypeColumn dataTypeFilterOpts.put(dataType.toUpperCase() + '_DATA', operators); for (Reports.FilterOperator fo : filterOperatorMap.get(dataType)) { operators.add(new SelectOption(fo.getName(), fo.getLabel())); } } return dataTypeFilterOpts; } public PageReference getReportInfo() { Reports.ReportDescribeResult descRes = Reports.ReportManager.describeReport(reportId); availableColumnFilters = new List<ColumnFilter>(); for (Reports.ReportTypeColumnCategory category : descRes.getReportTypeMetadata().getCategories()) { for (Reports.ReportTypeColumn col : category.getColumns().values()) { if (col.getFilterable()) { ColumnFilter cf = new ColumnFilter( col.getLabel(), col.getName(), col.getDataType().name() ); availableColumnFilters.add(cf); } } } return null; } public String getChartFilter() { return JSON.serialize(getSelectedFilters()); } private List<ColumnFilter> getSelectedFilters() { List<ColumnFilter> selectedFilters = new List<ColumnFilter>(); for (ColumnFilter cf : availableColumnFilters) { if (String.isNotBlank(cf.operator)) { selectedFilters.add(cf); } } return selectedFilters; } public class ColumnFilter { public ColumnFilter(String lab, String col, String dt) { label = lab; column = col; dataType = dt; } // Values needed for apex:analytics component public String column { get; set; } public String operator { get; set; } public String value { get; set; } // Values need for display and operator select list public String label { get; set; } public String dataType { get; set; } } }
Thanks for the help!!
- Chad Ritchie
- January 29, 2020
- Like
- 0
- Continue reading or reply
InboundEmail read questionnaire
Recently I've been tasked with sending a questionnaire to customers related to specific orders with an e-mail with a questionnaire, when the user replies the InboundEmail class needs to save the information sended back (Evaluation from 0 to 10), plus any comentaries.
Is there a way to achieve this natively or trough Apex?
I've searched the boards but wasn't able to find any solution related to my problem, in any case if it's a duplicate topic sorry in advance!
Thank you!
- Rafaetti
- January 28, 2020
- Like
- 0
- Continue reading or reply
Approval process email alert question. Need Apex?
I've got an interesting use case here. I've got an approval process built out on Opportunities. One of the managers wants an email anytime something is approved or rejected but only if the Oppty was created by one of the people on her team. Otherwise she doesn't want an email at all.
Any ideas on how to do this? In the approval process itself, I don't see a way to send an email alert based on a criteria. I know that I could create some formula field like a checkbox to return 'true' if the record was created by someone on her team, but I don't see a way to fire of an Approval Action based off a criteria.
So maybe a trigger then on approval? If so, what object would by trigger be on?
Thanks in advance everyone!
George
- George Laird 29
- January 24, 2020
- Like
- 0
- Continue reading or reply
how to iterate over map of Map<ID,List<String>>
- Hitesh chaudhari
- October 02, 2018
- Like
- 0
- Continue reading or reply
How do I go about highlighting blank fields?
- Daniel Bleasdale
- September 03, 2018
- Like
- 0
- Continue reading or reply
Why delete row action not call apex function?
<apex:form > <apex:pageBlock title="Your Carts:"> <apex:pageblockTable value="{!MapProducts}" var="a"> <apex:column > <apex:image width="100" height="100" value="{!URLFOR($Resource.ProductImage, 'ProductImage/' & MapProducts[a]['ImageName__c'])}"></apex:image> </apex:column> <apex:column headerValue="Name" value="{!MapProducts[a]['Name']}"/> <apex:column headerValue="Price" value="{!MapProducts[a]['Price__c']}"/> <apex:column headerValue="Amount" > <apex:inputText style="text-align:right;width:100px;" value="{!MapProducts[a]['Amount']}"/> </apex:column> <apex:column headerValue="Money" value="{!MapProducts[a]['Total']}"/> <apex:column > <apex:commandLink action="{!deleteItem}" reRender="MapProducts" ><apex:param assignTo="{!iKey}" value="{!a}" name="assignvalue" /> Remove Row</apex:commandLink> </apex:column> </apex:pageblockTable> <apex:pageBlock title="Total Money:"> <apex:outputText >{!iTotalMoney}</apex:outputText> </apex:pageBlock> </apex:pageBlock> </apex:form>
apex function:
public void deleteItem() { System.Debug('deleteItem') ; iTotalMoney=0; System.Debug(iKey) ; MapProducts.remove(iKey); for (Integer key : MapProducts.keySet()) { iTotalMoney +=Double.valueOf(MapProducts.get(key).get('Total')); } }
Log debug output
43.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;NBA,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,INFO 03:14:43.0 (94306)|USER_INFO|[EXTERNAL]|0057F000002yTNz|daitb@vnitsolutions.com|Pacific Standard Time|GMT-07:00 03:14:43.0 (138242)|EXECUTION_STARTED 03:14:43.0 (143358)|CODE_UNIT_STARTED|[EXTERNAL]|0667F000009PMhv|VF: /apex/carts 03:14:43.0 (360015)|VF_DESERIALIZE_VIEWSTATE_BEGIN|0667F000009PMhv 03:14:43.0 (7435075)|VF_DESERIALIZE_VIEWSTATE_END 03:14:43.0 (9840462)|SYSTEM_MODE_ENTER|true 03:14:43.0 (14743313)|SYSTEM_MODE_ENTER|true 03:14:43.0 (15488240)|VF_SERIALIZE_VIEWSTATE_BEGIN|0667F000009PMhv 03:14:43.0 (17250235)|VF_SERIALIZE_VIEWSTATE_END 03:14:43.20 (20160362)|CUMULATIVE_LIMIT_USAGE 03:14:43.20 (20160362)|LIMIT_USAGE_FOR_NS|(default)| Number of SOQL queries: 0 out of 100 Number of query rows: 0 out of 50000 Number of SOSL queries: 0 out of 20 Number of DML statements: 0 out of 150 Number of DML rows: 0 out of 10000 Maximum CPU time: 0 out of 10000 Maximum heap size: 0 out of 6000000 Number of callouts: 0 out of 100 Number of Email Invocations: 0 out of 10 Number of future calls: 0 out of 50 Number of queueable jobs added to the queue: 0 out of 50 Number of Mobile Apex push calls: 0 out of 10 03:14:43.20 (20160362)|CUMULATIVE_LIMIT_USAGE_END 03:14:43.0 (20198901)|CODE_UNIT_FINISHED|VF: /apex/carts 03:14:43.0 (21042239)|EXECUTION_FINISHEDlog not exist text: deleteItem
Why delete row action not call apex function?
- dai tran 6
- June 18, 2018
- Like
- 0
- Continue reading or reply
how to get my record type name in before insert in apex
How to get the record type name in before insert.
Requiremnet is need to check in if condition for record type name
Ex : if(record type name= 'A' )
- Radha Rathinavel Pandian
- March 08, 2018
- Like
- 0
- Continue reading or reply
EmailMessage object permissions problem: the user does not see incoming emails
We have a custom EmailService for inbound messages written in apex, which is processing Inbound email messages and then showing them in a lightning component.
The type od the received email object is EmailMessage. On the production org, when the system administrator is logged in, he sees all the needed incoming emails (the component is showing them as it should be, querying also works). It all worked well in our sandbox though.
The problem is when the user is logged in. The component does not show any emails and they are not visible also by querying. The problem is I suppose with some permissions, but the EmailMessage object in our org is not customizable when it comes to permissions (everything is set to default and is not changeable). The user has a company community licence. Any help or suggestion would be greatly appreciated.
- Biljana Miceva 7
- February 26, 2018
- Like
- 0
- Continue reading or reply
how to update the ownerId field in the ContentDocument object
can anyone provide me a solution on how to update the ownerId field in the ContentDocument object. i have tried doing this with a trigger on ContentDocument object but it does not seems to work
- Soumyodeep Guha 8
- February 13, 2018
- Like
- 0
- Continue reading or reply
Convert Trigger to Apex class
I have this trigger that I would like to convert to an apex class and I would like to add some code to the class. The trigger changes contacts to the account owner id when the account owner is changed. What I would like to add is something that also changes the contact owner when a contact is created or added to the account.
Here is the trigger I have.
trigger AlignContactownertoAccountOwner on Account (after insert,after update) {
Set<Id> accountIds = new Set<Id>();
Map<Id, String> oldOwnerIds = new Map<Id, String>();
Map<Id, String> newOwnerIds = new Map<Id, String>();
List<Contact> contactUpdates = new List<Contact>();
for (Account a : Trigger.new)
{
if (a.OwnerId != Trigger.oldMap.get(a.Id).OwnerId)
{
oldOwnerIds.put(a.Id, Trigger.oldMap.get(a.Id).OwnerId);
newOwnerIds.put(a.Id, a.OwnerId);
accountIds.add(a.Id);
}
}
if (!accountIds.isEmpty()) {
for (Account acc : [SELECT Id, (SELECT Id, OwnerId FROM Contacts) FROM Account WHERE Id in :accountIds])
{
String newOwnerId = newOwnerIds.get(acc.Id);
String oldOwnerId = oldOwnerIds.get(acc.Id);
for (Contact c : acc.Contacts)
{
if (c.OwnerId == oldOwnerId)
{
Contact updatedContact = new Contact(Id = c.Id, OwnerId = newOwnerId);
contactUpdates.add(updatedContact);
}
}
}
}
update contactUpdates;
}
Any help would be great.
Thanks,
Michael
- Michael Lindsay 4
- February 13, 2018
- Like
- 0
- Continue reading or reply
Too many future calls: 51 Error - Please Help
Any idea how to alleviate gettign this error? Here is my trigger and class code....thank you all for any help you can provide....
Trigger:
trigger DeleteExtraBookingsTrigger on Opportunity (after insert) { For(Opportunity opps : Trigger.new){ If(opps.Auto_Bookings__c == True){ DeleteExtraBookingsClass.deleteRecords(Trigger.newMap.keySet()); } } }
Class code:
public class DeleteExtraBookingsClass { @future public static void deleteRecords(Set<ID> oppIdsToDelete){ List<Opportunity> opp = [SELECT ID, Armor_Product_Category__c From Opportunity WHERE ID IN : oppIdsToDelete AND Auto_Bookings__c = True AND (Armor_Product_Category__c = null or Armor_Product_Category__c = 'Armor | null')]; If(opp.size()>0){ delete opp; database.emptyRecycleBin(opp); } } }
- Shawn Reichner 29
- February 09, 2018
- Like
- 0
- Continue reading or reply
It is possible to create a folder in Google Drive?
I have a requirement to store information from different Contacts in Google Drive. My problem is that I would like to create a directory dynamically for each new contact and I have not found much information on how to do it from apex. Has anyone had success performing this functionality?
Greetings thank you!
- Gabriel E Casarsa
- February 02, 2018
- Like
- 0
- Continue reading or reply
Trigger was fired after update, when the trigger has to be fired before update
The below trigger was fired after updating the field twice, but it was not fired before update.
trigger age on Account (before update) { Map<Id,Account> ageMap = new Map<Id,Account>(); Account[] acct = [SELECT Id,Age__c FROM Account WHERE Id IN : Trigger.newMap.keySet()]; for(Account a : trigger.new){ if(a.age__c != null){ ageMap.get(a.Id); a.Is_Age_Updated__c = true; } else{ ageMap.get(a.Id); a.Is_Age_Updated__c = false; } } }
- poojaa
- February 02, 2018
- Like
- 0
- Continue reading or reply
Avoid creating duplicate records if that product already exists
I have two objects called product and product details. Product field is lookup on product details.
In product details object, if I have a product detail record pd1 with product p1, I shouldn't be able to create or update
another product detail pd2 with product p1.
How can I achieve this?
- Daniel K
- January 31, 2018
- Like
- 0
- Continue reading or reply
Can we call a trigger when we click a custom button on a VF page.
I have written a trigger .I want this trigger to be executed when clicked on a custom button in a VF page. Can anyone help me out with this?
Thanks.
- teena jacob
- January 31, 2018
- Like
- 0
- Continue reading or reply
Primary and Secondary Master Detail Relationships
- Belinda Burger
- January 30, 2018
- Like
- 0
- Continue reading or reply
Need trigger to pull Opp name
I'm new to triggers and struggling with this. I need a trigger that pulls the Opportunity name and creates a new record in my custom object, AE Opp. I do not need it to create a lookup or link it to the opp, i just need it to create a whole new record so that I can create a task on it.. Is this feasible?
- dcgb2332
- January 18, 2018
- Like
- 0
- Continue reading or reply
Email Options in Salesforce
I have a requirement to send out 50000 email to a un-verified email address every day, but due to 5000 email limit, we cannot.
Do you have any solution which can be implemented?
Background:
We are using a custom VF page to filter out records which need to send an email.
An ideal solution would be a button over the VF page which can send email just like Salesforce button using some tool.
Thanks in Advance.
- GauravGarg
- December 06, 2019
- Like
- 0
- Continue reading or reply
lightning flow: Choice values are not retained
The problem I am facing here is, the customer selects the choice values and navigates forward (next) but in-case if he returns back to the screen, the selected value is reset to default i.e. the choice has been reset.
Can you please provide an optimal solution out-of-the-box to fix this issue. Thanks
- GauravGarg
- July 27, 2018
- Like
- 0
- Continue reading or reply
How to create Map<String, String> from Account List?
Thanks in advance.
- GauravGarg
- July 02, 2018
- Like
- 0
- Continue reading or reply
How can we store and display Uploaded files' name in Lightning flow using lightning component.
My Requirement is to display the "files name" of uploaded document. I have attribute "Uploaded file names" and store into a collection variable, but when I choose this option, my flow screen is showing blank.
I want to display all the file name that are uploaded.
Any idea?
Thanks in advance.
- GauravGarg
- June 19, 2018
- Like
- 0
- Continue reading or reply
I want to load external Javascript with locker service enabled.
I am new to lightning. My requirement is to load external Minify javascript file which will run a demo or walkthru over the object records, Dashboard to enlight customer to use Lightning.
Currently, the same has been working in salesforce classic, but in lightning it is not allowed and throwing error.
Do anyone facing the same issue?
- GauravGarg
- July 01, 2017
- Like
- 0
- Continue reading or reply
App Exchange tool for Salesforce - Siebel integration ( two way).
Is there any third party (app exchange) tool.
Or we should go with customized code.
Please suggest.
- GauravGarg
- June 08, 2017
- Like
- 0
- Continue reading or reply
Sharing Records are not queried in Test Class.
My Batch job is working as expected and creating those record perfectly.
But, the issue is in Test Class:
- I have created one createOpportunity() method, and create two Opportunities.
- Both the opportunities have Manager / Senior Manager field populated with User.
- Now, when I run this method, It will cover my Batch job and create sharing records ( that I can debug in batch job).
- If I am trying to query those sharing record in Test Class using below query, it is giving 0 records.
- SELECT Id, manager__c, senior_manager__c, rowcause from Opportunity.
- GauravGarg
- June 06, 2017
- Like
- 0
- Continue reading or reply
How can we stop Salesforce Standard Javascript from running behind the VF pages.
Can you please provide me some idea to avoid running these standard Javascript libraries.
- GauravGarg
- May 09, 2017
- Like
- 0
- Continue reading or reply
Superbadge lightning showing in active module as I have already completed it 2 months back. Please let me know how can I fix this
I have completed my Lightning Superbadge two months ago and since then it is showing in active module. Please help me out how can I fix this. I already had contacted with salesforce trailhead but they are providing no help.
Thanks,
Gaurav
- GauravGarg
- January 01, 2017
- Like
- 0
- Continue reading or reply
I have completed my Lightning super bade still status did not change.
Today I have completed my Lightning super badge module, still it is showing under Active module.
Please suggest how can I fix this.
Thanks,
Gaurav
- GauravGarg
- September 23, 2016
- Like
- 0
- Continue reading or reply
Get record from a List based on current record being updated
I was wondering. What is the best way to get the record from a list based on the currecnt record.
For example I have this list where I am grabbing all the records where the ProjectT Name is 'Closed Templates'
cprojects = [SELECT Id, ProjectT__r.Name, Cand_Project__c,Cand__c FROM Project__c WHERE ProjectT__r.Name =: 'Closed Templates'];In a nother method how can I grab the the record/field from the list based on the current record. What I am trying to go is query all of the records that meet the criteria so that I only have to query it once in the class but need to be able to get a record from list based on the current record being updated.
Thanks,
P
- Phuc Nguyen 18
- June 10, 2020
- Like
- 0
- Continue reading or reply
How to compare Rollup summary field which is counting no of hired people with the picklist value which is containing value of total no. of positions.
if they are equal no. then I want to update status of my job.in apex trigger.
- shraddha kadam
- June 10, 2020
- Like
- 0
- Continue reading or reply
Authenticate then open External URL from within Salesforce
In my mind what I need to do is simple, but everything I seem to find leads me down a path of complex development. Maybe I'm searching on the wrong terms.
Here is what I'm trying to do.
Use case - User needs to click a button(action, etc.) in a record to open to an externally hosted site to perform a task that ties to the SF record they're working in. On click, it would automatically authenticate to the site, pass initial values, and then open the web page in an iframe (preferable), or in a new browser window/tab with the initial values populated.
Basic logic - (at least in JSON)
3. Display that session - bearer token in the header, sessionid appended to the end of a static external URL
The primary issue for me is the structure of this. Writing the code itself isn't really an issue. It's where to put it all and bring it all together.
I had thought this could all be in done in a VF page, but that doesn't seem to be the case. Some people recommend using Canvas, but that seems to be way over the top.
Any help, guidance is greatly appreciated.
- Rudabaugh
- June 10, 2020
- Like
- 0
- Continue reading or reply
Get the Id of inserted records and the id of parent (get id of inserted quote and its opporunity)
insert cloneQuoteList;
I am inserting the list of quote.
How can i get the Opportunity Id and Inserted qute id after the insert.
I want to use the Ids to insert the cloned quote line items
thank you
- Ab
- June 09, 2020
- Like
- 0
- Continue reading or reply
Why my lead assignment rule is not working?
I have configured my salesforce org with JOT form. My lead assignment rule is also active. But due to some reason it is not working. Can any one suggest me why it is not working and hot to run it.
Thank you
- Ishan Singh 4
- June 09, 2020
- Like
- 0
- Continue reading or reply
doubt on Data Import
When Updating Contact Email Through Import Wizard, i tried using two approaches
1. contact name, account name
2. contact email id,contact id
Both work fine,but when there are duplicate contacts under account then only one of them gets updated . Hence i assume option 2 is the right way to go.Can someone confirm?
- alekhya buduguppa
- June 09, 2020
- Like
- 0
- Continue reading or reply
Error: Invalid case comment body
Not able to use case comment object.Initially we write few lines of code on case comment object and it was working. But, now when we are trying to change the code its is showing invalid variable commentbody error message. Then i reverted all the changes and just tried to save the method as earlier. But now also im not able to save that class. Same code is not giving errors in UAT but getting error in Dev sandbox.
public static void UpdateCaseComment(string Id, string comment ){
casecomment cc=new casecomment();
cc.Id=Id;
cc.commentbody=comment;
try{
update cc;
}catch(Exception e){
System.debug('er->'+e);
}
}
This is my code
Please let me know what is causing this issue.
- SaiKrupa J
- June 09, 2020
- Like
- 0
- Continue reading or reply
Passing a non-edited value from an Aura component back during save
Now the start of the "week" is changeable. In other words some weeks can be seven days long, others can be five depending on the start date. I'm able to get things working fine, creation of new records, extra except for the division part when updating previous records.
Essentially using the "Power of One," I'm summing up the number of days in the "weekly record" and displaying it in the consolidated view for users. I would like to pass that number back to SFDC so the updated values are divided by that summed "Power of One" value.
Hoping some one can help me figure out how to force the component to return the sum even though it hasn't changed, kind of like the ID value. If that value is rreturned, I don't have to do a SOQL query to find the number of daily records for the various "weekly" records.
Thanks.
- PugetSoundJim
- June 09, 2020
- Like
- 0
- Continue reading or reply
Ending position out of bounds
I have a 'Text Area (Long)' Field called All_Products_List__c wich will be populate by a trigger. To avoid error, i want to limit the number of caracter sto the max vaklue of Text Area (Long).
The code save well but when i run the test class, The error is: "Ending position out of bounds: 131072".
trigger DeliveryNotification on Item_Distributed__c (after update, after insert, after delete, after undelete){ List <Item_Distributed__c> deliveryItems = (Trigger.isInsert|| Trigger.isUnDelete) ? Trigger.new : Trigger.old; List <Id> delveryId = new List<Id> (); String fullProduct; for (Item_Distributed__c allDeliveryItems : deliveryItems) { delveryId.add(allDeliveryItems.Delivery__c); } List< Delivery__c> deliveryList = [ SELECT id, All_Products_List__c, (SELECT Product_With_UOM__c from Items_Distributed__r ) From Delivery__c Where id in:delveryId]; for (Delivery__c del: deliveryList){ if (del.Items_Distributed__r.size()>0){ //camp.Product_With_UOM__c = string.valueOf(del.Items_Distributed [0].Product_With_UOM__c); del.All_Products_List__c = ''; for(Item_Distributed__c member : del.Items_Distributed__r ) fullProduct = del.All_Products_List__c + member.Product_With_UOM__c + ' ,'; del.All_Products_List__c = fullProduct.substring(131072); } else del.All_Products_List__c = null; } update deliveryList;
- Girbson Bijou 8
- June 08, 2020
- Like
- 0
- Continue reading or reply
Adding multiple custom object records on one visualforce page
I have a custom object (Warehouse Visit) that is the child record of Contact. I'd like to click a button on the Warehouse Visit tab where multiple records can be created on one Visualforce page. Basically, I'd like staff to be able to log multiple visits on one page rather than add them one by phone.
On the VF page, I'd like a link that says "add" to allow staff to add multiple rows for each record (3-4 fields). At the end of each row, I want a Remove or X link to remove that row if it was created in error. Then, on save, I'd like it to redirect back to the Warehouse Visit tab.
I haven't started building the VF page yet, but I'd like to enter about 4 fields, including a lookup to the Contact, a couple of date/time fields, and maybe a checkbox or picklist.
I have started with this Apex class code, based on a previous button I had help developing, but I'm getting an error. Can anyone help fix this code?
public class WarehouseVisitController {
public List<Warehouse_Visit__c> wvRecord{get; set;}
public Integer wvIndex {get; set;}
public WarehouseVisitController (){
wvRecord = new List<Warehouse_Visit__c>();
wvRecord.add(new Warehouse_Visit__c);
} #this is where the error is happening
public void addWarehouseVisit () {
wvRecord.add(new Warehouse_Visit__c);
}
public void removeWarehouseVisit() {
wvIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('wvIndex'));
wvRecord.remove(wvIndex);
}
public PageReference save() {
upsert wvRecord;
PageReference page = new PageReference('/');
return page;
}
public PageReference cancel() {
PageReference page = new PageReference('/' );
return page;
}
}
- BlairB
- June 08, 2020
- Like
- 0
- Continue reading or reply
SOQL - Unrelated Objects
Is it possible to join two unrelated objects (Account with Custom Object) using SOQL?
Basically I need to update the Account object with a field from the unrelated custom object. Where Account.custom_field == Customobject.custom_Field.
The update can be done in bulk, hence governor limits (SOQL -100) should be respected.
Thanks!
- cad aus
- June 05, 2020
- Like
- 0
- Continue reading or reply
Need help with Batch Apex.
I am trying to use batch apex to call the google maps api to avoid limits on @future calls. We have a custom Property__c object and we need to be able load hundreds of records at a time and have them get geocoded.
I can tell from the debug statements that I am successfully passing a set of Ids to the batch apex class. However the database.querlocator does not appear to be getting called. Here is the code:
public class batchPropertyGeocode implements Database.Batchable <sObject>, Database.AllowsCallouts, Database.Stateful { Set<Id> propsToGeocode = new Set<Id>(); //Constructor will take a set of Property Ids public batchPropertyGeocode(Set<Id> propsToGeocode) { this.propsToGeocode = propsToGeocode; System.debug('Creating list of Properties to Geocode: '+this.propsToGeocode); } public Database.QueryLocator start(Database.BatchableContext BC) { //Query Properties passed from Trigger System.debug('Querying to get Property addresses'); return Database.getQueryLocator([SELECT Property_City__c,PropertyState__c, Property_Street_Address__c,PropertyZipCode__c FROM Property__c WHERE Id IN :propsToGeocode]); } public void execute(Database.BatchableContext BC, List <Property__c> Propertyupdate) { List < Property__c > modifiedProps = new list <Property__c> (); for (Property__c prop: Propertyupdate) { //create a string for the address to pass to Google Geocoding API String geoAddress = ''; if(prop.Property_Street_Address__c!= null) geoAddress+= prop.Property_Street_Address__c+ ', '; if(prop.Property_City__c != null) geoAddress+= prop.Property_City__c+ ', '; if(prop.PropertyState__c!= null) geoAddress+= prop.PropertyState__c+ ', '; if(prop.PropertyZipCode__c!= null) geoAddress+= prop.PropertyZipCode__c; geoAddress = EncodingUtil.urlEncode(geoAddress, 'UTF-8'); System.debug('Url Encoded address: '+ geoAddress); try{ googleMapsJson gro = callGoogleApex(geoAddress); System.Debug(gro.results.size()); if(gro.results.size() > 0) { double lat = gro.results[0].geometry.location.lat; double lon = gro.results[0].geometry.location.lng; if (lat != null) { system.debug('lat is not null'); prop.Geolocation__Latitude__s = lat; prop.Geolocation__Latitude__s = lon; modifiedProps.add(prop); system.debug('Property Location: ' + Prop.Geolocation__Latitude__s ); } } else { System.Debug('nothing in list. what am i going to do?'); } } catch (Exception e) {} update modifiedProps; } } public static googleMapsJson callGoogleApex(string geoAddress) { // Key for Google Maps Geocoding API String geocodingKey = 'Actual Google API Key Here'; Http h = new Http(); HttpRequest req = new HttpRequest(); googleMapsJson gro = new googleMapsJson(); if (geoAddress != null) { req.setEndpoint('http://maps.googleapis.com/maps/api/geocode/json?address=' + geoAddress +'&key='+ geocodingKey+ '&sensor=false'); req.setMethod('GET'); req.setTimeout(6000); HttpResponse res = h.send(req); JSONParser parser = JSON.createParser(res.getBody()); while(parser.nextToken() != null) { if(parser.getCurrentToken()==JSONToken.START_OBJECT){ gro = (googleMapsJson) parser.readValueAs(googleMapsJson.class); } } } return gro; } public void finish(Database.BatchableContext BC) { } }I would really appreciate some help to get me over the hump.
- Ian Carswell 36
- June 05, 2020
- Like
- 0
- Continue reading or reply
trigger to prevent duplicate trigger.
Below is my code for the trigger for duplicate prevention on the account . It works well, but if I have 50k records this impacts scalability and not feasible.
So please any one can help to code in better way.
thanks in advance.
trigger AccountDuplicate on Account (before insert) {
List<Account> dup = new List<Account>();
dup = [Select id, Name from Account];
for(Account a:Trigger.New){
for(Account a1:dup){
if(a.Name==a1.Name){
a.Name.addError('Name already Exist ');
}
}
}
}
- Sonam Patil
- August 13, 2016
- Like
- 0
- Continue reading or reply
New Quote button is not visible
I have a problem with Opportunity related list Quotes.
I can't see the button "New Quote", I try to modify quote settings in the opportunity layout (like that https://success.salesforce.com/answers?id=90630000000D5QRAA0) but there's no button header, just the column one is visible. How can I do to solve my issue?
- caterina ferrigno 8
- August 01, 2016
- Like
- 0
- Continue reading or reply
- vincent van niekerk
- September 03, 2018
- Like
- 1
- Continue reading or reply
Conditionally URL Button
Hey Guys,
i am looking for a "best practice" solution, to create a conditionally url button. The button should be placed on the standard page layout.
Related to a value of the object, the button button should redirect the user to a page.
For example, if the status is x, redirect to a new task.
if the status is y, redirect to the homepage.
if the status is z, redirect to an external page.
Unfortunately, a javascript button is not a soultion for lightning.
I have created a controller and a methode to create a conditionally PageReference for each case. I dont think that this solution is best practice. Moreover, i used simply urls like
1new PageReference('https://...............+lead.id');
what is definitely not best practise. So my button opens the page which is fireing the action methode automatically.
Conclusion, i am looking for :
- a solution for lightning and classic
- a button placed on the standard page layout
- the button should redirect to different pages related to a value of the object
- a more best practice solution than mine
I appreciate your help !
Cheers,
Marry
- Marry Stein
- September 02, 2018
- Like
- 1
- Continue reading or reply
Data Integration Suggestions
- Yogesh Biyani
- February 25, 2018
- Like
- 1
- Continue reading or reply
Need To Know How is AWS (Amazon Web Services) different from Salesforce?
Amazon EC2 (AWS Certified)is an Infrastructure as a Service which offers pay-by-hour servers (EC2), storage (S3) etc. You bring your own software to the table – OS (Red Hat, Windows, whatever), Database (MySQL, Oracle, DB2, whatever), Search (your pick), Business Intelligence (Cognos, Oracle BI, whatever) – and then you piece it together and get it all to work. The benefits are that you can do whatever you want – and the con is you have to manage complexity yourself.
Force.com, by contrast, is a Platform as a Service that provides a pre-integrated offering that already has a database, search, BI Reports, identity/security etc. all built in – that you program using a Java-like language (Apex). With the newly announced VMforce, a VMware and Salesforce.com offering, you will be able to use Java soon. Force.com automatically backs up your data, manages upgrades (your apps don’t need to know if Force.com is running on database version 11i or 11g, Dell boxes or Sun boxes, Linux or Windows etc.)
Regards
Sarahjohn
- sarah john 4
- January 30, 2018
- Like
- 2
- Continue reading or reply
how to access multiple values from a custom setting in javascript on click button?
{!REQUIRESCRIPT("/xdomain/xdomain.js")} {!REQUIRESCRIPT("/soap/ajax/39.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/39.0/apex.js")} {!REQUIRESCRIPT("/support/console/39.0/integration.js")} var Program='{!Program_Member_MVN__c.Program_Name__c}'; var Pname=sforce.connection.query("Select Program__c from Program_Names__c"); var rec16 = Pname.getArray('records'); var status='{!Program_Member_MVN__c.Status_MVN__c}'; var PmId='{!JSENCODE(Program_Member_MVN__c.Id)}'; var PName='{!Program_Member_MVN__c.Program_Name__c}'; var url; if (sforce.console.isInConsole()) { if(Program == rec16){ alert("You are on the wrong Program") } else if(status == 'On Therapy') { url = "/apex/Milestone_skip?id="+PmId; window.open(url,'_blank','toolbar=0,location=0,menubar=0,width=800,scrollbars'); } else { alert("Patient must be ‘On-Therapy’ before skipping to a milestone"); } }
This is my java script on click button code.In this i am querying custom setting here:var Pname=sforce.connection.query("Select Program__c from Program_Names__c");
And i want to compare to field to show a alert.So i have to multiple values in custom setting.So how can i access all the values given in the custom setting in the java script code?
- Varun Annadata
- July 07, 2017
- Like
- 1
- Continue reading or reply