- Srinivas S
- SMARTIE
- 830 Points
- Member since 2016
- Salesforce Senior Developer
-
ChatterFeed
-
21Best Answers
-
1Likes Received
-
5Likes Given
-
4Questions
-
115Replies
Combine Lightning Components in VisualForce Pages
I'm developing some Lightning Components and i have a big project in VisualForce Pages.
I want to replace some of the features for Lightning Components, for instance, i have a search system, and the ideia is to replace that search with a lightning component search.
Can i combine a lightning component search with results in VisualForce Pages?
My doubt is: If i search something, the results will appear in the VisualForce Pages like normal? Or i need to create another component to show the results?
Thanks
-
- Ricardo Coutinho 7
- August 02, 2016
- Like
- 0
- Continue reading or reply
sandbox refresh time interval means?
does it mean the time taken to complete the refresh from prod to test?
-
- hemanth tanguturi 5
- June 06, 2016
- Like
- 2
- Continue reading or reply
Problem with Upsert Trigger on OpportunityLineItem
We've been working on this trigger for a week now and to say its drive us crazy is an understatement. We've been round the housees a little simply on the basis we're trying to expose the line items to a visualforce force.com profile page - If anyone has done this before then they'll appreciate the headache products creates.
We've had several workable inserts that have either repeatedly inserted new lines or that insert without populating the opportunity lookup. We've got to the point that our trigger hits a dml error using the field references we've provided. Assuming that if we collect the opportunity ID from the line item and that this isn't populated prior to insert is why we hit the error. We've seen this done where the ID is insert after the save and therefore bypassing the error but unfortunately this surpasses our knowledge.
Please can someone help and advise the appropriate change in order to fix this?
trigger BidProductsInsert on OpportunityLineItem(after insert, after update) { Map<Id, OpportunityLineItem> opl = new Map<Id, OpportunityLineItem>(); Map<Id, Opportunity> opps = new Map<Id, Opportunity>(); Map<Id, PricebookEntry> prices = new Map<Id, PricebookEntry>(); Map<opportunitylineitem, bid_products__c> lines = new Map<opportunitylineitem, bid_products__c>(); for(OpportunityLineItem record: Trigger.new) { opps.put(record.OpportunityId, null); prices.put(record.PricebookEntryId, null); } opl.putAll([SELECT Id, OpportunityID FROM OpportunityLineItem WHERE Id IN :opl.keySet()]); prices.putAll([SELECT Id, Product2.Name, Product2Id FROM PricebookEntry WHERE Id IN :prices.keySet()]); for(OpportunityLineItem record: Trigger.new) { lines.put(record, new bid_products__c( Name='Opp-Product', Product2__c=prices.get(record.PricebookEntryId).Product2Id, Unit_Price__c=record.UnitPrice, Quantity__c=record.Quantity, Product_Name__c=prices.get(record.PricebookEntryId).Product2.Name, Opportunity__c=opl.get(record.OpportunityID).Id, Id=record.Bid_Products__c)); } upsert lines.values(); for(OpportunityLineItem record: Trigger.new) { record.bid_products__c = lines.get(record).Id; } }
Thank you,
Snita
-
- Snita Lal
- June 06, 2016
- Like
- 0
- Continue reading or reply
pre insert trigger question
I am reviewing some code that I inherited :-)
It uses a "before" trigger as follows. It is trying to take a variable from the Quote and
copy it to the OpportunityLineItem.
trigger OpportunityProductTrigger on OpportunityLineItem (before insert, before update) { if(Trigger.isBefore){ OpportunityProductServices.addParentSortOrderNumber(trigger.new); } }
The method being called is as follows:
public class OpportunityProductServices{ // Populating Base OpportunityLine Item's Sort Order number on Add-on OLI's public static void addParentSortOrderNumber(List<OpportunityLineItem> lst_OLI){ Set<String> set_OpportunityIds = new Set<String>(); // Creating Set of Opportunity Ids for which Opportunity Lineitem is created or updated for(OpportunityLineItem var : lst_OLI){ set_OpportunityIds.add(var.OpportunityId); } Map<Id, Map<Id, QuoteLineItem>> map_Opprtunity2Quote = new Map<Id, Map<Id, QuoteLineItem>>(); // Getting List of QLI for Opportunity ids which has Quote Quote Synced for(QuoteLineItem var : [Select Id, SortOrder, Base_OLI_Id__c, Quote.OpportunityId from QuoteLineItem WHERE Quote.isSyncing=true and Quote.OpportunityId IN : set_OpportunityIds]){ if(map_Opprtunity2Quote.containsKey(var.Quote.OpportunityId)){ map_Opprtunity2Quote.get(var.Quote.OpportunityId).put(var.Id, var); }else{ Map<Id, QuoteLineItem> map_QuoteLine = new Map<Id, QuoteLineItem>(); map_QuoteLine.put(var.Id, var); map_Opprtunity2Quote.put(var.Quote.OpportunityId, map_QuoteLine); } } for(OpportunityLineItem var : lst_OLI){ Map<Id, QuoteLineItem> map_QuoteLine = map_Opprtunity2Quote.get(var.OpportunityId); for(QuoteLineItem QLI : map_QuoteLine.values()){ // Putting Sort Number on Custom Field of OLI if(var.SortOrder == QLI.SortOrder && QLI.Base_OLI_Id__c != null){ var.Base_OLI_Sort_Number__c = map_QuoteLine.get(QLI.Base_OLI_Id__c).sortOrder; } } } } }
My question is this:
Since there are no DML operations being performed in the called method, does this
code *do* anything?
Is the "trigger.new" that is passed in directly from the trigger to the method passed by reference, and
therefore setting Base_OLI_Sort_Number__c actually sets it somehow?
Thanks,
Mitch
-
- Mitch McConnell
- June 02, 2016
- Like
- 0
- Continue reading or reply
Controller method doesn't rerender pageBlock
My aim is showing the pageBlock named iconGallery, when the user click on the commandLink "Show Gallery". If I put the "loadImage" method's code inside Constructor, everything goes perfect. So I wonder if the problem is between the Controller and VF page.
VF page:
<apex:page id="NewAchievement" controller="NewAchievement_Controller"> <!-- Import Component --> <c:loadingSpinner /> <!-- Page Header --> <apex:sectionHeader title="Achievement Edit" subtitle="New Achievement"/> <!-- Begin Form --> <apex:form > <apex:actionFunction action="{!loadImages}" name="loadImages" reRender="iconGallery" oncomplete="hideLoadingDialog();" /> <apex:pageBlock title="Achievement Edit" mode="edit"> <!-- Button Section --> <apex:pageBlockButtons location="top"> <apex:commandButton value="Save" action="{!save}" /> <apex:commandButton value="Save & New" action="{!saveNew}" /> <apex:commandButton value="Cancel" action="{!cancel}" /> </apex:pageBlockButtons> <!-- Fields --> <apex:pageBlockSection columns="1" showHeader="true" title="Information"> <apex:inputField value="{!achievement.Name}" required="true" /> <apex:inputField value="{!achievement.Category__c}" required="false" /> <apex:inputField value="{!achievement.Points__c}" required="true" /> <apex:inputField value="{!achievement.Validation_Criteria__c}" required="true" style="width: 300px"/> </apex:pageBlockSection> <!-- Icon Selection --> <apex:pageBlockSection title="Select Icon"> <apex:commandLink value="Show gallery" action="{!loadImages}" reRender="iconGallery" onclick="showLoadingDialog();" oncomplete="hideLoadingDialog();" /> <apex:image value="https://eu6.salesforce.com/servlet/servlet.FileDownload?file=01558000000UI88" /> </apex:pageBlockSection> </apex:pageBlock> <!-- Icon Gallery --> <apex:pageBlock title="Icon Gallery" id="iconGallery" rendered="{!isClicked}"> <apex:repeat value="{!allLinks}" var="item"> <apex:outputLink value="http://www.google.es"> <apex:image onclick="String" value="{!item}" style="padding-right: 10px; padding-bottom: 10px"/> </apex:outputLink> </apex:repeat> </apex:pageBlock> </apex:form> </apex:page>
Controller:
public class NewAchievement_Controller { public Achievement__c achievement {get; set;} public List<Document> allImages {get; set;} public List<String> allLinks {get; set;} public Boolean isClicked {get; set;} public NewAchievement_Controller () { allImages = new List<Document>(); allLinks = new List<String>(); isClicked = false; } public PageReference saveNew() { try { insert achievement; } catch(System.DMLException e) { ApexPages.addMessages(e); return null; } return (new ApexPages.StandardController(new Achievement__c())).edit(); } public PageReference cancel() { return (new ApexPages.StandardController(achievement).view()); } public PageReference save() { try { upsert(achievement); } catch(System.DMLException e) { ApexPages.addMessages(e); return null; } PageReference redirectSuccess = new ApexPages.StandardController(achievement).view(); return (redirectSuccess); } public PageReference loadImages() { //LOAD EXISTING IMAGES (16x16) allImages = [SELECT Id FROM Document WHERE FolderId = '00l58000000hBuj']; String s = 'https://eu6.salesforce.com/servlet/servlet.FileDownload?file='; for(Integer i=0; i < (allImages.size()-106); i++) { Document d = allImages.get(i); allLinks.add(s + String.valueOf(d.Id)); } isClicked = true; return null; } }
Thank you in advance!
-
- Nerea Isabel González Gutiérrez 8
- May 26, 2016
- Like
- 0
- Continue reading or reply
prepopulating the phone field
I have field called phone in contact when i inserted the new contact or updated the contact of related account the account phone should be prepoulated in the contact phone field of the existing account using trigger.
Thanks in advance.
-
- kali charan
- May 25, 2016
- Like
- 0
- Continue reading or reply
Trigger at opportunity when stage changed from Closed won to Closed lost
I want my trigger to check a custom checkbox field (called Cancelled) when my opportunity stage changes from closed won to closed lost.
I know we can get that information from Opportunity Stage History reports also we can create a workflow rule (below)
1 AND(
2 ISCHANGED(IsWon),
3 PRIORVALUE(IsWon),
4 IsClosed,NOT(IsWon))
From a knowledge perspective how can I achieve this via trigger?
Thanks
-
- Nadeem Uddin 2
- May 25, 2016
- Like
- 0
- Continue reading or reply
Create a Trigger on Task object, to send an Email Notification to the assigned user, Upon creating a New Task.
Im learning salesforce and im unable to figure out how to implement the above program, can anyone help me with my querry?
Thanks in advance
-
- Begginer
- May 24, 2016
- Like
- 0
- Continue reading or reply
Assigning attachment on lead conversion to opportunity.
I have a problem with apex code thats supposed to delete attachment added to account after lead conversion, and then add the copy of this attachment to opportunity.
But when i convert my lead, nothing happens, i checked the Attachment.ParentID with system debug and i found something strange.
The normal id of account is 0013600000LjlAi, but when in the debug its 0013600000LjlAiAAJ, do you know why that would happen?
Here is part of code responsible for getting parendId:
________
trigger Update_Attachment_Parent on Attachment (after insert, after update) {
//Create a List to store the Ids of Attachments to be deleted
List<Id> forDeletionIds = new List<Id>();
for (Attachment a : trigger.new){
//Check to see if the Attachment has an Account as the Parent Record
if(a.ParentId.getSobjectType() == Account.SobjectType){
//Select the Primary Opportunity from the Account
Account parent = [SELECT Primary_Opportunity__c FROM Account WHERE ID = :a.ParentId];
System.debug('The parentID is: ' + a.ParentId);
________
Side note: Person Accounts are enabled for our org and every converted account is a person account.
-
- Jarosław Kołodziejczyk 12
- May 20, 2016
- Like
- 0
- Continue reading or reply
A trigger to copy the value of a custom picklist from Account to another custom picklist in Contact?
I need to have a trigger to copy the value of a picklist from Account to its related Contacts (another custom picklist).
The requirement is only to be copied if in the Contact poage the picklist is empty.
I tried this trigger:
trigger UpdateContactRegione on Contact(before Insert, before Update) { for(Contact Cont: Trigger.new){ Account acct = [select id,Regione__c from Account where Id=:Cont.AccountId]; if(Cont.Regione__c == null) Cont.Regione__c= acct.Regione__c; } }
But it worksonly if I change the picklist in Contact and not viceversa.
Any suggestions?
Thanks,
Skender
-
- SKollcaku
- May 20, 2016
- Like
- 0
- Continue reading or reply
how to get selected picklist value in controller
<apex:selectList id="selected_list" value="{!val}" required="false" size="1">
<apex:selectOption itemvalue="AllTime" itemLabel="AllTime"/>
<apex:selectOption itemvalue="CurrentWeek" itemLabel="CurrentWeek"/>
<apex:selectOption itemvalue="LastWeek" itemLabel="LastWeek"/>
<apex:actionSupport event="onchange" action="{!viewData}" reRender="block"/>
</apex:selectList>
Controller:
public string val{get;set;}
public pageReference viewData(){
getTimesheetEntries();
return null;
}
public List<Time_Log__c>getTimesheetEntries()
{
system.debug('****************************Value*****************************'+val);
List<Time_Log__c> timesheetentries = new List<Time_Log__c>();
if(val =='CurrentWeek')
{
system.debug('****************************+++++++++INSIDE if Current Week+++++++*****************************');
timesheetentries = [select id,name,Allocation__c,Assigned_to__c,Action_Status__c,End_Date__c,Billable__c,Start_Date__c,Milestone__c,Progress_Percentage__c,Role__c,Projects__c ,Activity_Type__c,Task_If_Assigned__c,Time_Spent_Hrs__c from Time_Log__c where LastModifiedDate = THIS_WEEK];
}
if(val =='LastWeek')
{
system.debug('****************************+++++++++INSIDE if LAst Week+++++++*****************************');
timesheetentries = [select id,name,Allocation__c,Assigned_to__c,Action_Status__c,End_Date__c,Billable__c,Start_Date__c,Milestone__c,Progress_Percentage__c,Role__c,Projects__c ,Activity_Type__c,Task_If_Assigned__c,Time_Spent_Hrs__c from Time_Log__c where LastModifiedDate = LAST_WEEK];
}
else
{
system.debug('****************************+++++++++INSIDE else+++++++*****************************');
timesheetentries = [select id,name,Allocation__c,Assigned_to__c,Action_Status__c,End_Date__c,Billable__c,Start_Date__c,Milestone__c,Progress_Percentage__c,Role__c,Projects__c ,Activity_Type__c,Task_If_Assigned__c,Time_Spent_Hrs__c from Time_Log__c];
}
return timesheetentries ;
}
-
- nikita dhamal
- May 11, 2016
- Like
- 0
- Continue reading or reply
bind sobjects to picklist
I have a requirement where I need to bind sobjects to an picklist and show it in visual force page.
Can it be done using dynamic apex ?
pls let me know.
pooja
-
- pooja biswas
- May 10, 2016
- Like
- 0
- Continue reading or reply
System.DmlException: Insert failed. First exception in test class
public class AddmultipleAccountsController {
Account account = new Account();
public list<Account> listAccount{ get; set; }
public AddmultipleAccountsController()
{
listAccount=new list<Account>();
listAccount.add(account);
}
Public void addAccount()
{
Account acc = new Account();
listAccount.add(acc);
}
public PageReference saveAccount() {
for(Integer i=0; i<listAccount.size(); i++)
{
insert listAccount;
}
return Page.addmore;
}
}
test class
@isTest
public class addmul_test
{
static testmethod void addtest()
{
AddmultipleAccountsController ar=new AddmultipleAccountsController();
pagereference pf=Page.addmore;
ar.addAccount();
ar.saveAccount();
}
}
-
- anuj huria
- May 10, 2016
- Like
- 0
- Continue reading or reply
convert text to integer in SOQL
Can anyone can help me out:
-How to convert text to integer in SOQL.
Really appreciate quick response
-
- buggs sfdc
- May 05, 2016
- Like
- 0
- Continue reading or reply
test classes
Is it possible to deployee the code to production.
-
- Srinivas Annam
- May 05, 2016
- Like
- 0
- Continue reading or reply
Cross object Apex trigger test class help
I have been pounding my head into my keyboard for the last day trying to figure out how to write a test class for this trigger that will get more than %66. I am very new to writing apex, but I have written a few triggers for single objects and this is my first for a cross object trigger and for some reason the test class is just not making sence to me. So that brings me here. I am wondering if anyone can help me write a test class that will allow deployment into production. Any an all help is appricated :) I wouldn't mind a little explanation at how you came to the conclusion as well. The more you know! :)
The code is pretty simple. It checks for a created task with a specific subject line, then changes the "Status" of the associated lead.
trigger changeLeadStatus_Disconnected on Task (before insert, before update) { String desiredNewLeadStatus = 'Wrong #/Disconnected'; List<Id> leadIds=new List<Id>(); for(Task t:trigger.new){ if(t.Subject=='Call with PhoneBurner - BAD PHONE'){ if(String.valueOf(t.whoId).startsWith('00Q')==TRUE){ leadIds.add(t.whoId); } } } List<Lead> leadsToUpdate=[SELECT Id, Status FROM Lead WHERE Id IN :leadIds AND IsConverted=FALSE]; For (Lead l:leadsToUpdate){ l.Status=desiredNewLeadStatus; } try{ update leadsToUpdate; }catch(DMLException e){ system.debug('Leads were not properly updated. Error: '+e); } }
-
- Timothy Wiech
- May 03, 2016
- Like
- 0
- Continue reading or reply
Need help with an Apex class/trigger to selectively prevent account deletion
My requirements are as follows:
I need to restrict the deletion of account records to System Admins only, when the value of a certain checkbox field is set to true on the account.
My research tells me I need a trigger, but since we don't have individual triggers I need to do this in our AccountTriggerHandler apex class.
Any advice is appreciated!
-
- Scott Shoning
- May 02, 2016
- Like
- 0
- Continue reading or reply
How to display the page view count in vf page
I have one custom object called AddsViewList.In that i have 2 custom fields i.e,AddsName,Count..in custom object i have 10 sample records.First req is i have to get the record name py passing id in vf page..Second one is i have to display the page view count whenever the user refresh the page and the count should be updated...
Can anyone pls provide the code..
-
- Geetha sai
- May 02, 2016
- Like
- 0
- Continue reading or reply
Email validation in visualforce
-
- phani kumar 70
- May 01, 2016
- Like
- 0
- Continue reading or reply
Delete Notes
Sorry for the noobie question. Having serious trouble trying to get some help. The 'contact us' page just redirects to the 'help launch page' on multiple platforms.
Anyways I need support. I need to delete all notes from my account as I just starting to use the developer edition but somehow over 2500 'notes' have been created and take up all of the 5mb storage. I didn't create the notes, and I am not sure where they came from. I did install some apps but I don't think they can create notes without my knowledge. It is not possible to delete through the data loader or by any other means I have seen or at least nothing has worked. Also I am unable to install any app from marketplace to do the job since I don't have any storage. What can I do?
Any help would be really appreciated. Thanks:)
-
- Richard Burke 11
- April 28, 2016
- Like
- 0
- Continue reading or reply
javaScript error while creating the component from the visualforce page in Latest Chrome Browser if the Locker service is activated.
Uncaught (in promise) TypeError: Cannot set property 'innerHTML' of null
at AuraInstance.message (/auraFW/javascript/zsWZWPmRKjQt6GsG2UtCYg/aura_proddebug.js:18708)
at AuraInstance.handleError (/auraFW/javascript/zsWZWPmRKjQt6GsG2UtCYg/aura_proddebug.js:18676)
at AuraInstance.$reportError$ (/auraFW/javascript/zsWZWPmRKjQt6GsG2UtCYg/aura_proddebug.js:18685)
at reportError (/auraFW/javascript/zsWZWPmRKjQt6GsG2UtCYg/aura_proddebug.js:18523)
Please help me with any work around.
Thanks,
Srinivas
-
- Srinivas S
- March 30, 2017
- Like
- 0
- Continue reading or reply
Managed Package: How to take the precautions to avoid failing the test classes in the target Org?
After making the managed package if the client installs the package and makes any field mandatory at field-level or introduces a validation rule test classes in the package will fail.
How to handle the above scenario to make sure to avoid failing the test classes even after introducing a validation rules or if they make any field mandatory at field level?
Please share your ideas?
Thanks,
Srinivas
-
- Srinivas S
- July 25, 2016
- Like
- 0
- Continue reading or reply
Not able to delete a field in field set in managed package
We are having two managed packages –
- Primary Package
- Secondary Package
- By installing the Primary Package we are working for the Secondary Package.
- In secondary package all the objects, fields, field sets of the primary package will be available.
- In one of the object of the Primary Package we have created a field set additionally.
- In Primary Package few fields are removed and created one more version of the primary package.
- In Secondary Package development instance upgraded the Primary Package to the latest version.
- Trying to remove the deleted field (as part of later primary package it is deleted) from the field set which is created in Secondary Package Instance for one of the object of primary package.
Result: Not able to delete the field from a field set which is created in Secondary Package (field set is created for one of the object of primary package).
Please let me know if there is any work around. We have tried to remove in Force.com IDE also nothing worked out.
Thanks,
Srinivas
-
- Srinivas S
- June 22, 2016
- Like
- 0
- Continue reading or reply
Displaying more than 500 records in lightning table visualforce
1. We have created a lightning component and lightning application.
2. Referred lightning app in visualforce page to display the table of records.
When we are displaying the bulk records (more than 500), it is taking more time (>30 Sec) due to huge logic in the javaScript helper.
Instead of displaying all the 500 records at a time which is consuming more time, I want to load 5 records first later it can process for the remaining records.
If anyone of you having suggestions please let me know.
Thanks,
Srinivas
-
- Srinivas S
- May 18, 2016
- Like
- 1
- Continue reading or reply
Displaying more than 500 records in lightning table visualforce
1. We have created a lightning component and lightning application.
2. Referred lightning app in visualforce page to display the table of records.
When we are displaying the bulk records (more than 500), it is taking more time (>30 Sec) due to huge logic in the javaScript helper.
Instead of displaying all the 500 records at a time which is consuming more time, I want to load 5 records first later it can process for the remaining records.
If anyone of you having suggestions please let me know.
Thanks,
Srinivas
-
- Srinivas S
- May 18, 2016
- Like
- 1
- Continue reading or reply
Combine Lightning Components in VisualForce Pages
I'm developing some Lightning Components and i have a big project in VisualForce Pages.
I want to replace some of the features for Lightning Components, for instance, i have a search system, and the ideia is to replace that search with a lightning component search.
Can i combine a lightning component search with results in VisualForce Pages?
My doubt is: If i search something, the results will appear in the VisualForce Pages like normal? Or i need to create another component to show the results?
Thanks
- Ricardo Coutinho 7
- August 02, 2016
- Like
- 0
- Continue reading or reply
interview based question
2,can we process one record in batch apex class?
- ajay ambati
- June 29, 2016
- Like
- 0
- Continue reading or reply
authentication failure, what should I do?
Here's what I did:
1) set myself up with an intro developer account on developer.salesforce.com
2) naturally, i've got admin privileges. Verified that API is enabled. Created the security token for myself and captured it.
3) set up an app:
- enabled OA/Auth,
- set scope to 'Full Data Access",
- set the callback URL to https://test.salesforce.com (is this right!?
fired off the standard curl that everyone else uses, get nothing but "authentication failures".
Here's the CURL I'm using:
curl -v https://test.salesforce.com/services/oauth2/token \
-d "grant_type=password"
-d "client_id=XXXXXXXXXXXXX"
-d "client_secret=YYYYYYYYYYYYYY"
-d "username=login@myco.com"
-d "password=PWORDSECURITYTOKEN"
What did I miss?
- Alek Mesarovich
- June 17, 2016
- Like
- 0
- Continue reading or reply
JSON data becoming Null After Deserialzation
Hi All,
I have one JSON Data , i am serializing that data, but it is becoming NULL after deserialization.
I want to access the value form JSON data into the VF page.
Here is my JSON Data:
{ "mindTouchPage":{ "id":"1", "guid":"00000000000000000000000000000000", "draftstate":"inactive", "href":"https://steadfast-prod.mindtouch.us/@api/deki/pages/1?redirects=0", "deleted":"false", "datecreated":"Fri, 10 Jun 2016 20:30:17 GMT", "language":"en-US", "namespace":"main", "path":{ "seo":"true", "type1":"fixed", "text":"" }, "subpages":{ "mindTouchPage":[ { "id":"288", "guid":"a7afffb2634b453485bff59faed455f6", "draftstate":"inactive", "href":"https://steadfast-prod.mindtouch.us/@api/deki/pages/288?redirects=0", "deleted":"false", "datecreated":"Fri, 10 Jun 2016 21:33:04 GMT", "language":"en-US", "namespace":"main", "path":{ "seo":"true", "type1":"custom", "text":"The_MindTouch_Workbook/Chapter_I_-_Understand_users_&_groups/010_User_types_defined" }, "subpages":"", "title":"1. User types defined", "uriui":"https://steadfast-prod.mindtouch.us/?title=The_MindTouch_Workbook/Chapter_I_-_Understand_users_%26_groups/010_User_types_defined" }, { "id":"289", "guid":"88eae1c3ae25449eb27a518bfabf51ae", "draftstate":"inactive", "href":"https://steadfast-prod.mindtouch.us/@api/deki/pages/289?redirects=0", "deleted":"false", "datecreated":"Fri, 10 Jun 2016 21:33:09 GMT", "language":"en-US", "namespace":"main", "path":{ "seo":"true", "type1":"custom", "text":"The_MindTouch_Workbook/Chapter_I_-_Understand_users_&_groups/011_Create_groups" }, "subpages":"", "title":"2. Create groups", "uriui":"https://steadfast-prod.mindtouch.us/?title=The_MindTouch_Workbook/Chapter_I_-_Understand_users_%26_groups/011_Create_groups" }, { "id":"290", "guid":"e6da4dab743846f3bef6cd2826964937", "draftstate":"inactive", "href":"https://steadfast-prod.mindtouch.us/@api/deki/pages/290?redirects=0", "deleted":"false", "datecreated":"Fri, 10 Jun 2016 21:33:20 GMT", "language":"en-US", "namespace":"main", "path":{ "seo":"true", "type1":"custom", "text":"The_MindTouch_Workbook/Chapter_I_-_Understand_users_&_groups/012_Create_users" }, "subpages":"", "title":"3. Create users", "uriui":"https://steadfast-prod.mindtouch.us/?title=The_MindTouch_Workbook/Chapter_I_-_Understand_users_%26_groups/012_Create_users" } ] } } }
Here is My Wrapper Class
public class JSON2Apex { public list<MindTouchPage> mindTouchData; public list<path> pathData; public class Path { public String seo; public String type1; public String text; } public class MindTouchPage { public String id; public String guid; public String draftstate; public String href; public String deleted; public String datecreated; public String language; public String namespace; public Path path; public Subpages subpages; public String title; public String uriui; } public class Subpages { public List<MindTouchPage> mindTouchPage; } public static JSON2Apex parse(String json) { return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class); } }
controller class
global with sharing class ViptelaCustLandingController { global static String responseData{get;set;} global static String status{get;set;} public boolean isUserAuthenticated{get;set;} Public Integer closeCaseCount{get;set;} public Integer openCaseCount{get;set;} public JSON2Apex mindTouch{get;set;} public MindTouchDataWrapper wrapper { get; set; } // Constructor public ViptelaCustLandingController(){ // Get the count of closed Cases closeCaseCount = [SELECT COUNT() FROM CASE WHERE status = 'closed']; openCaseCount = [SELECT COUNT() FROM CASE WHERE status !='closed']; } // Code will invoke on pageLoad public pageReference redirectToCustomAuthPage(){ if(UserInfo.getUserType()=='Guest'){ return new pagereference ('/viptelaLoginController'); } else{ // status = 'User Authenticated'; // Call the webService Function // getDataFromMindTouch(); isUserAuthenticated = TRUE; getDataFromMindTouch(); return null; } } // WebService Method to Call the "MindTouch" API // @future(callout = true) public void getDataFromMindTouch(){ status = 'method Called'; System.debug('WebService Method Called'); // MindTouch User Name String userName = '**********'; String password = '***********'; String mindTouchURL = 'https://***************'; // Prepare the HTTP request and response HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); // Construct Authorization and Content Header // Blob headerValue = Blob.valueOf(userName+':'+password); Blob headerValue = Blob.valueOf(username + ':' + password); String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue); // String authorizationHeader = 'Basic'+ EncodingUtil.base64Encode(headerValue); // req.setHeader('Authorization', 'Basic UmlzaGF2OlJpc2hAMTk5MSo='); req.setHeader('Authorization', authorizationHeader); req.setHeader('Content-Type','application/json'); // Set Method,endpoint,and body req.setMethod('GET'); req.setEndpoint(mindTouchURL); try{ res = http.send(req); System.debug('Response is =======' + res.getBody()); //responseData = res.toString(); responseData =res.getBody(); status = 'TRUE'; System.debug('response data variable value is' +responseData ); //**************************Added by V****************************************** //To overcome the limitation of @ variable in response, it is converted to the SFDC acceptable form using replace keywork //and same is reference in the MindTouchWrapper Class responseData = responseData.replace('"page"', '"mindTouchPage"'); responseData = responseData.replace('"@id":', '"id":'); responseData = responseData.replace('"@guid":', '"guid":'); responseData = responseData.replace('"@draft.state":', '"draftstate":'); responseData = responseData.replace('"@href":', '"href":'); responseData = responseData.replace('"@deleted":', '"deleted":'); responseData = responseData.replace('"date.created":', '"datecreated":'); responseData = responseData.replace('"@seo":', '"seo":'); responseData = responseData.replace('"@type":', '"type1":'); responseData = responseData.replace('"#text":', '"text":'); responseData = responseData.replace('"uri.ui":', '"uriui":'); System.debug('response2 data variable value is' +responseData); //Parse is the deserialize method in the MindTouchWrapper class // MindTouchWrapper mindTouch = MindTouchWrapper.parse(responseData); mindTouch = JSON2Apex.parse(responseData); System.debug('Deserialized data is '+mindTouch); //*************************Added by V******************************************* }Catch(System.CalloutException e){ System.debug('ERROR' +e); System.debug('Response is ' + res.getBody()); } } }
VF Code to get Data
<apex:pageBlock > <apex:pageBlockSection columns="2"> <apex:repeat value="{!mindTouch}" var="data"> <apex:outputText value="{!data.id}"></apex:outputText> </apex:repeat> </apex:pageBlockSection> </apex:pageBlock>
Please hlep me to show data from JSON into VF page.
- Rishav
- June 17, 2016
- Like
- 0
- Continue reading or reply
Maximum number of user records retrieved in a single query
Using query, it is possible to get all user details from SalesForce (ex: /services/data/v{version#}/query/?q={SOQL queyy} ). I would like to know what is the maximum number of user records retrieved in a single query.
Please advise.
- Krishna Prasad P S
- June 17, 2016
- Like
- 0
- Continue reading or reply
how to set second level approver for a record using apex coding in approval process
I have created the dynamic approval process on a custom object. In this i can able to send send one approval request. If i am trying to set one more approver id to req.setNextApproverIds(new Id[] {apl[1].approver__c}) method, I am getting exception. How can i send request to the second approver ? Please any body can help me.
- vijaya kudupudi
- June 17, 2016
- Like
- 0
- Continue reading or reply
Sharing documents between two salesforce orgs
Is there any feature in salesforce to transfer(share) files or documents between two salesforce orgs?
Thanks in advance
- Lavanya Gottumukkala 8
- June 08, 2016
- Like
- 0
- Continue reading or reply
Why do we use WHATID instead of the WHAT field on tasks?
In the Bulk Apex Triggers Trailhead piece we are told to use WhatId to set the related field of a new task. However, when I look at the actual fields of the Task object the field name is actually What. When I try to use What I get an error. How would I have known to use the WhatId name instead and why is this in general?
- Timothy Winter
- June 06, 2016
- Like
- 0
- Continue reading or reply
sandbox refresh time interval means?
does it mean the time taken to complete the refresh from prod to test?
- hemanth tanguturi 5
- June 06, 2016
- Like
- 2
- Continue reading or reply
Problem with Upsert Trigger on OpportunityLineItem
We've been working on this trigger for a week now and to say its drive us crazy is an understatement. We've been round the housees a little simply on the basis we're trying to expose the line items to a visualforce force.com profile page - If anyone has done this before then they'll appreciate the headache products creates.
We've had several workable inserts that have either repeatedly inserted new lines or that insert without populating the opportunity lookup. We've got to the point that our trigger hits a dml error using the field references we've provided. Assuming that if we collect the opportunity ID from the line item and that this isn't populated prior to insert is why we hit the error. We've seen this done where the ID is insert after the save and therefore bypassing the error but unfortunately this surpasses our knowledge.
Please can someone help and advise the appropriate change in order to fix this?
trigger BidProductsInsert on OpportunityLineItem(after insert, after update) { Map<Id, OpportunityLineItem> opl = new Map<Id, OpportunityLineItem>(); Map<Id, Opportunity> opps = new Map<Id, Opportunity>(); Map<Id, PricebookEntry> prices = new Map<Id, PricebookEntry>(); Map<opportunitylineitem, bid_products__c> lines = new Map<opportunitylineitem, bid_products__c>(); for(OpportunityLineItem record: Trigger.new) { opps.put(record.OpportunityId, null); prices.put(record.PricebookEntryId, null); } opl.putAll([SELECT Id, OpportunityID FROM OpportunityLineItem WHERE Id IN :opl.keySet()]); prices.putAll([SELECT Id, Product2.Name, Product2Id FROM PricebookEntry WHERE Id IN :prices.keySet()]); for(OpportunityLineItem record: Trigger.new) { lines.put(record, new bid_products__c( Name='Opp-Product', Product2__c=prices.get(record.PricebookEntryId).Product2Id, Unit_Price__c=record.UnitPrice, Quantity__c=record.Quantity, Product_Name__c=prices.get(record.PricebookEntryId).Product2.Name, Opportunity__c=opl.get(record.OpportunityID).Id, Id=record.Bid_Products__c)); } upsert lines.values(); for(OpportunityLineItem record: Trigger.new) { record.bid_products__c = lines.get(record).Id; } }
Thank you,
Snita
- Snita Lal
- June 06, 2016
- Like
- 0
- Continue reading or reply
updating multiple records from child to parent in anonymous window hlp me plssss
Line: 35, Column: 1
System.ListException: Duplicate id in list: 00128000003LLRkAAO
OK
pls hlp me
:*the following below is my code:*
list<account> lst1 = new list<account>();
list<schema.contact> lst = [select id,name,account.name,account.Fax from contact where account.Fax != null];
for(schema.contact c:lst)
{
system.debug('DISPLAY'+c.account.name);
system.debug('@@@@@@'+c.account.Fax);
//Account ac = [select id,name,fax from account where id=:c.account.id];
c.account.Fax='040-567-234';
lst1.add(c.account);
}
update lst1;
- ajay ambati
- June 02, 2016
- Like
- 0
- Continue reading or reply
pre insert trigger question
I am reviewing some code that I inherited :-)
It uses a "before" trigger as follows. It is trying to take a variable from the Quote and
copy it to the OpportunityLineItem.
trigger OpportunityProductTrigger on OpportunityLineItem (before insert, before update) { if(Trigger.isBefore){ OpportunityProductServices.addParentSortOrderNumber(trigger.new); } }
The method being called is as follows:
public class OpportunityProductServices{ // Populating Base OpportunityLine Item's Sort Order number on Add-on OLI's public static void addParentSortOrderNumber(List<OpportunityLineItem> lst_OLI){ Set<String> set_OpportunityIds = new Set<String>(); // Creating Set of Opportunity Ids for which Opportunity Lineitem is created or updated for(OpportunityLineItem var : lst_OLI){ set_OpportunityIds.add(var.OpportunityId); } Map<Id, Map<Id, QuoteLineItem>> map_Opprtunity2Quote = new Map<Id, Map<Id, QuoteLineItem>>(); // Getting List of QLI for Opportunity ids which has Quote Quote Synced for(QuoteLineItem var : [Select Id, SortOrder, Base_OLI_Id__c, Quote.OpportunityId from QuoteLineItem WHERE Quote.isSyncing=true and Quote.OpportunityId IN : set_OpportunityIds]){ if(map_Opprtunity2Quote.containsKey(var.Quote.OpportunityId)){ map_Opprtunity2Quote.get(var.Quote.OpportunityId).put(var.Id, var); }else{ Map<Id, QuoteLineItem> map_QuoteLine = new Map<Id, QuoteLineItem>(); map_QuoteLine.put(var.Id, var); map_Opprtunity2Quote.put(var.Quote.OpportunityId, map_QuoteLine); } } for(OpportunityLineItem var : lst_OLI){ Map<Id, QuoteLineItem> map_QuoteLine = map_Opprtunity2Quote.get(var.OpportunityId); for(QuoteLineItem QLI : map_QuoteLine.values()){ // Putting Sort Number on Custom Field of OLI if(var.SortOrder == QLI.SortOrder && QLI.Base_OLI_Id__c != null){ var.Base_OLI_Sort_Number__c = map_QuoteLine.get(QLI.Base_OLI_Id__c).sortOrder; } } } } }
My question is this:
Since there are no DML operations being performed in the called method, does this
code *do* anything?
Is the "trigger.new" that is passed in directly from the trigger to the method passed by reference, and
therefore setting Base_OLI_Sort_Number__c actually sets it somehow?
Thanks,
Mitch
- Mitch McConnell
- June 02, 2016
- Like
- 0
- Continue reading or reply
Method does not exist or incorrect signature in test class
I have a Custom Controller like
public class classname{ public classname(){ ---------Do Sum Logic--------- } } .............................. I have written in test like PageReference pageRef = Page.MyPage; pageRef.getparameters().put('id','obj.id); Test.setCurrentPageReference(pageRef); classname cont = new classname(); cont.classname() ------------------------------Showing error hereAny Suggestions
Regards,
VSK
- VSK98
- May 31, 2016
- Like
- 0
- Continue reading or reply
problem with mass email message
- Gopinath Lakkimsetti
- May 31, 2016
- Like
- 0
- Continue reading or reply
Batch Apex, callouts and updates
I am stuck on this. I am getting the "You have uncommitted work pending. Please commit or rollback before calling out" CalloutException, even though I am doing the operations in the right order as I understand it.
The batch job has to select accounts that need updating, call a webservice to query some data, and update the accounts with this new information.
Below is a simplified version of my code. Basically:
- In the start() method I run a query on Account and return a QueryLocator
- In the execute() method I loop through the List<Account>, do as many callouts as needed and set the relevant fields in the Account objects; at the end of the loop I do one update operation.
This should preserve the rule "no not do callouts after DML operations". But the second callout after I first set the fields is failing. It seems though setting field values on the object counts as DML, even though I am not performing the update operation yet.
Does that make sense? How can it be fixed? Or is it a whole different thing that I am doing wrong?
Thanks in advance.
global class AccountsUpdateWebService implements Database.Batchable<sObject>, Database.AllowsCallouts, Database.Stateful { global Database.QueryLocator start(Database.BatchableContext bc){ String query = 'Select Id, Name FROM Account ...'; return Database.getQueryLocator(query); } global void execute(Database.BatchableContext bc, list<Account> accounts) { List<Account> toupdate = new List<Account>(); for (Account account: accounts) { // Callout to web service that retrieves address info WSData wsdata = WebService.getData (account.Name); account.BillingStreet = wsdata.Street; account.BillingPostalCode = wsdata.PostalCode; toupdate.add (accounts); } update toupdate; } global void finish(Database.BatchableContext bc) { } }
- Mario V
- May 27, 2016
- Like
- 0
- Continue reading or reply
Controller method doesn't rerender pageBlock
My aim is showing the pageBlock named iconGallery, when the user click on the commandLink "Show Gallery". If I put the "loadImage" method's code inside Constructor, everything goes perfect. So I wonder if the problem is between the Controller and VF page.
VF page:
<apex:page id="NewAchievement" controller="NewAchievement_Controller"> <!-- Import Component --> <c:loadingSpinner /> <!-- Page Header --> <apex:sectionHeader title="Achievement Edit" subtitle="New Achievement"/> <!-- Begin Form --> <apex:form > <apex:actionFunction action="{!loadImages}" name="loadImages" reRender="iconGallery" oncomplete="hideLoadingDialog();" /> <apex:pageBlock title="Achievement Edit" mode="edit"> <!-- Button Section --> <apex:pageBlockButtons location="top"> <apex:commandButton value="Save" action="{!save}" /> <apex:commandButton value="Save & New" action="{!saveNew}" /> <apex:commandButton value="Cancel" action="{!cancel}" /> </apex:pageBlockButtons> <!-- Fields --> <apex:pageBlockSection columns="1" showHeader="true" title="Information"> <apex:inputField value="{!achievement.Name}" required="true" /> <apex:inputField value="{!achievement.Category__c}" required="false" /> <apex:inputField value="{!achievement.Points__c}" required="true" /> <apex:inputField value="{!achievement.Validation_Criteria__c}" required="true" style="width: 300px"/> </apex:pageBlockSection> <!-- Icon Selection --> <apex:pageBlockSection title="Select Icon"> <apex:commandLink value="Show gallery" action="{!loadImages}" reRender="iconGallery" onclick="showLoadingDialog();" oncomplete="hideLoadingDialog();" /> <apex:image value="https://eu6.salesforce.com/servlet/servlet.FileDownload?file=01558000000UI88" /> </apex:pageBlockSection> </apex:pageBlock> <!-- Icon Gallery --> <apex:pageBlock title="Icon Gallery" id="iconGallery" rendered="{!isClicked}"> <apex:repeat value="{!allLinks}" var="item"> <apex:outputLink value="http://www.google.es"> <apex:image onclick="String" value="{!item}" style="padding-right: 10px; padding-bottom: 10px"/> </apex:outputLink> </apex:repeat> </apex:pageBlock> </apex:form> </apex:page>
Controller:
public class NewAchievement_Controller { public Achievement__c achievement {get; set;} public List<Document> allImages {get; set;} public List<String> allLinks {get; set;} public Boolean isClicked {get; set;} public NewAchievement_Controller () { allImages = new List<Document>(); allLinks = new List<String>(); isClicked = false; } public PageReference saveNew() { try { insert achievement; } catch(System.DMLException e) { ApexPages.addMessages(e); return null; } return (new ApexPages.StandardController(new Achievement__c())).edit(); } public PageReference cancel() { return (new ApexPages.StandardController(achievement).view()); } public PageReference save() { try { upsert(achievement); } catch(System.DMLException e) { ApexPages.addMessages(e); return null; } PageReference redirectSuccess = new ApexPages.StandardController(achievement).view(); return (redirectSuccess); } public PageReference loadImages() { //LOAD EXISTING IMAGES (16x16) allImages = [SELECT Id FROM Document WHERE FolderId = '00l58000000hBuj']; String s = 'https://eu6.salesforce.com/servlet/servlet.FileDownload?file='; for(Integer i=0; i < (allImages.size()-106); i++) { Document d = allImages.get(i); allLinks.add(s + String.valueOf(d.Id)); } isClicked = true; return null; } }
Thank you in advance!
- Nerea Isabel González Gutiérrez 8
- May 26, 2016
- Like
- 0
- Continue reading or reply
Interview Question for all SFDC position
Hi,
If you have to take an interview of any salesforce position, what all question could you ask ?
Salesforce Developer - Skills -Apex , Force.com API , AppExchange, S-Control .
Please feel free to ask any questions ?
Thanks
- ronir
- February 04, 2009
- Like
- 0
- Continue reading or reply
Lightning Component > JavaScript Helper/Controller --> Set javaScript Collection is not working from summer'16
Set collection (I guess all the Collections) in lightning component's javaScript Helper/Controller is not working from Summer'16, It is throwing the following error -
TypeError: Set is not a Constructor (or)
TypeError: Set is not a Function.
Sample Code:
var s = new Set();
Note:
1. Before Summer'16 upgrade it was working.
2. I have included the above sample code in the javaScript of the Visualforce, It is working. Only the Lightning Component is causing the issue.
Please help me with a work around or let me know if you have any suggestions.
Thanks,
Srinivas
- Srinivasa Somu
- June 14, 2016
- Like
- 1
- Continue reading or reply
Disabling a lookUp inputfield on vf page
- Bhakti Gujarathi
- June 03, 2016
- Like
- 1
- Continue reading or reply
Sort data based on column heading in table in lightning
- Diwanshu setia 2
- May 24, 2016
- Like
- 1
- Continue reading or reply
How to list inheriting classes from an abstract class
I'm struggling with SF docs / forums / google and I don't succeed to find a response to a simple question:
How to list classes inheriting from a super class ?
Example :
public abstract MyRootAbstractClass { public virtual String getLabel() {return null ;} } public class MyFirstChildClass extends MyRootAbstractClass { public override String getLabel() {return 'MyFirstChildClassLabel' ;} } public class MySecondChildClass extends MyRootAbstractClass { public override String getLabel() {return 'MySecondChildClassLabel' ;} }
I need to be able to create a method who can return 'MyFirstChildClassLabel','MySecondChildClassLabel'
I anyone is able to fill the blank part in my code, I would be enternally thankful :)
Type RootClassType = Type.forName('MyRootAbstractClass'); ///// // WHAT TO PUT HERE ??? :'( ///// List<String> AvailableChildClassList = new List<String>(); for (String ChildClass : ChildClassList) { ClassType = Type.forName(ChildClass); SomeInterface ClassInstance = (SomeInterface)ClassType.newInstance(); String ChildClassLabel = ClassInstance.getLabel(); AvailableChildClassList.add(ChildClassLabel); } return AvailableChildClassList;
Note: some code parts are missing about interface management but it's ok i know how to manage it :)
Many thanks , best regards & have a nice day :)
- Nicolas Vuillamy
- May 24, 2016
- Like
- 1
- Continue reading or reply
ui:message component is not capturing "click" event
My component:
<aura:component access="global">
<ui:outputText value="simple text" click="{!c.onClick}"/>
<ui:message title="Confirmation" severity="confirm" closable="true" click="{!c.onClick}">
This is a confirmation message.
</ui:message>
</aura:component>
My JS Controller:
({
onClick: function(cmp) {
alert("Clicked");
}
})
Note that when I click on ui:outputText I do get the alert popup. But clicking on the ui:message does not give me the alert.
According the lightning developer document, the ui:message is supposed to support click event.
Thank you for the help!
- ssgmail
- May 18, 2016
- Like
- 1
- Continue reading or reply