• Manohar kumar
  • NEWBIE
  • 380 Points
  • Member since 2016

  • Chatter
    Feed
  • 10
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 20
    Questions
  • 107
    Replies
Hi ALL,

I have a requirement where I have to display a record with a different color based on the picklist value selected.

I have created a custom object called "CaseComments"  Picklist field name "visible to" which has "Internal" and "external" as value, If I choose Internal the record should be in Blue color likewise if I choose External the record should be in Green color.

Thanks in advance.

 
Am the system admin, I created free developer edition org with my email address but now I changed the network location, So when I tried to login showing invalid passoword and When I tried to RESET the passowod getting mail as  "We recently received a request to reset the Salesforce password for the username chandra@teqforcesolutions.com.For security reasons, your Salesforce administrator hasn’t approved logging in or resetting your password from the network location you used. Try logging in again by connecting to an approved network location and logging in with your existing password. If you still have issues, reset your password from that approved location.
If you didn't ask for your password to be reset, contact your Salesforce administrator."

I tried to reach support team they are mailing me the same steps and they are asking me to file a case, Hell man am unable to login to org they are asking to file a case and we cannot file a case from free developer org.

So anyone has solution please help me out, I have implemented lot of logics inthat org so I cannot afford to leave it 

so please please help me out inthis  
Hello,

I have a trigger that is updating a value on a parent record.
The trigger run on the custom object "Cost_line_item__c" and updates value on the parent opportunity.

I would like this trigger to run only for a specific record type id of the opportunity (so, the parent object).

My trigger (working) is:
Trigger UpdateOpportunityBV on Cost_line_item__c(After Insert, After Update, After Delete, After UnDelete){
    
    List<ID> opportunityIds = New List<ID>();
	List<ID> mylistIds = New List<ID>();
    
    If(Trigger.IsInsert || Trigger.IsUpdate || Trigger.IsUnDelete){
        For(Cost_line_item__c oli: Trigger.New){
            if(oli.Opportunity__c  != null){
                opportunityIds.add(oli.Opportunity__c);
				mylistIds.add(oli.Id);
            }  
        }
    }
    If(Trigger.IsDelete){
        For(Cost_line_item__c con: Trigger.Old){
            opportunityIds.add(con.Opportunity__c);
			mylistIds.add(con.Id);
        }
    }
     
    List<opportunity> opportunityListToUpdate = New List<opportunity>();
    Decimal RollupAmount = 1;
    For(Opportunity opt: [Select Id, Number_of_beneficiaries__c, (Select ID, Value__c FROM Cost_line_items__r WHERE Used_for_BV_calculation__c=true) FROM Opportunity WHERE ID = :opportunityIds]){
		for(Cost_line_item__c con:opt.Cost_line_items__r){
			RollupAmount = RollupAmount * con.Value__c;
		}
		opt.tech_cost_line_calculation__c = RollupAmount;
        opt.Amount = RollupAmount * opt.Number_of_beneficiaries__c;
		opportunityListToUpdate.add(opt);
    }
     
     
    try{
        Update opportunityListToUpdate;
    }
     Catch(Exception E){
        System.Debug('Error Message: ' + e.getMessage());
    }
}
I tried to replace the line 
if(oli.Opportunity__c  != null){
By
if(oli.Opportunity__c  != null && oli.Opportunity__r.RecordTypeid=='0121r0000003Qzk')
But it doesn't work (nothing happens).

Any suggestions?
So this is my Battch class and Test class.. but it only have 45%  coverage. How to make it 100%?
global class AwesomeCBBatch implements Database.Batchable<sObject>
{
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        Decimal amt = 500;
	String query = 'SELECT Id, Contact__c, Amount FROM Opportunity WHERE Contact__c != null AND Amount >=: amt';
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, List<Opportunity> scope)
    {
        Map<Id, Contact> conts = new Map<Id, Contact>();
        for ( Opportunity opp : scope)
        {
            if(!conts.containsKey(opp.Contact__c) {
            conts.put(opp.Contact__c, new Contact(Id = opp.Contact__c, Awesome__c = true));
	    }
        }
        update conts.values();
    } 

    global void finish(Database.BatchableContext BC)
    {

    }

}
 
@isTest

public class TestAwesomeCBBatch {
    static testMethod void testAwesomeCBBatch() {
		
        Contact con = new Contact();
        con.FirstName = 'Test';
        con.LastName = 'Contact';
        con.Awesome__c = false;
        
        List<Opportunity> newopp = new List<Opportunity>();
        for (integer i = 0; i < 200; i++) {
            Opportunity o = new Opportunity();
            o.Name = 'TestOpp';
            o.Contact__c = con.Id;
            o.Amount = 600;
            o.CloseDate = Date.today();
            o.StageName = 'Prospecting';
            newopp.add(o);
        }
        insert newopp;
        
        Test.startTest();
        AwesomeCBBatch b = new AwesomeCBBatch();
        Database.executeBatch(b);
        Test.stopTest();
    }
}
Hi everyone 
my question is 

How Many way to create multi-select picklist. Please solve


Thanks
Hi,

I want to prevent a non administrator user to delete closed won opportunities.

I think a trigger can be a good solution.
 
trigger ClosedWonOpportunityTrigger on Opportunity (before delete) {
    for(Opportunity o: Trigger.Old)
        if($Profile.Name <> "System Administrator" && o.stagename=='Closed Won’)
        	o.addError(‘You cannot delete a Closed Won Opportunity. Please contact the Accounting Department. Thank you.’);
}

Do you think this apex can work?

Thank you.

Referencing this unsolved post: https://success.salesforce.com/answers?id=90630000000h86rAAA

The ISBLANK (ParentID) formula doesn't actually tell me if it is a parent, it simply checks to see if there is a Parent ID.

My organization has multi-level hierarchies with our accounts, such as Grandparent --> Parent --> Child

The ISBLANK checkbox only works for the very top level (i.e. Grandparent) and doesn't work at the 2nd (Parent Level). 

I'd like to be able to find out if an Account has children accounts beneath it, not whether there are parents above it. Because it can be the case that an Account is both a parent and a child account.

 

Hi, 
I'm having a hard time covering this Controller Extension,  any example code?
Thanks!!!

public with sharing class currentbilling {
public final Account acc {get; set;}
public integer countActRec {get; set;}
public  Object sumAmount{set;get;}
Set<ID> countr = new Set<ID>();  
   public currentbilling(ApexPages.StandardController controller) {
       this.acc = (Account)controller.getRecord();
   }
   public List<OpportunityLineItem> oppoproRecords{get;set;} 
public void FetchData() {
  oppoproRecords = [SELECT Id, Opportunityid, Opportunity.Name ,  PricebookEntry.Product2.Name , Discounted_Rate__c, Advertiser_Account__c,  Opportunity.Contract_End_Date__c  FROM OpportunityLineItem Where Advertiser_Account__c = :acc.id and  Opportunity.StageName  = 'Contract Executed' and (Cancellation_Date__c = null or Cancellation_Date__c > Today) ];
if(oppoproRecords.isEmpty()){
  ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'There is no executed opportunities with actives products for this account.'));
}
  for (OpportunityLineItem rec : oppoproRecords) {
   countr.add(rec.Opportunityid);
   }
  countActRec =   [SELECT count() From Opportunity Where id in :countr];
  AggregateResult[] groupedResults   = [SELECT SUM(Discounted_Rate__c)aver FROM OpportunityLineItem Where Advertiser_Account__c = :acc.id and  Opportunity.StageName  = 'Contract Executed' and (Cancellation_Date__c = null or Cancellation_Date__c > Today)];
  sumAmount = groupedResults[0].get('aver');
}
}
------------
H,

I have a object called Media_Deliverable__c that has master detail relationship with Media_Plan__c.

In Media_Plan__c I have a button that renders as PDF. I need to get information from its related list items from Media_Deliverable into this PDF as well. How can I do this?

Thanks,
Arman 
  • December 19, 2016
  • Like
  • 0

Hi,
I have a Page and a controller.

In my page I am doing something like, when we select a radio button only some portion of the page will get rendered=true.
But when I click radio button it takes some time to load. So I would like to display some message like "loading" on the page, while it is loading.
Can anyone plz help me with the code?

Thanks in advance

Hi, 

I have a scenerio where i need to update account status. I have one object named "Application" which is a child object of Account. 
If any of the Application status is "Rejected" then i have to put rejected on the account status. Which  i am doing with the after insert, after update and after delete trigger on "Application". But my requiremnt is if user changes status manually on accunt, then don't update status ever.

How can i achieve this. Any help will be appriciated.  

Thanks,
Manohar

 

Hi All, 

I just created a new org. So it may be some thing wrong with the permission. I created one custom action which is clling a lightning app. lightning app is showing records of taks. i dont have any record trypes with the object. Lightning action is present on a custo object. I added that action on the layout also in "Salesforce1 and Lightning Experience Actions" section. But still i cant see that in the layout. 

i also tried making global action and addeed to the global result. But still no luck. 

Is there anything else i should try?

Thanks,
Manohar

 

 


I am very new to lightning. I made one component and put it in a lightning app. Like this

<aura:application extends="force:slds">
<c:Screenshow/>
</aura:application>


And i am calling this on a click event like this.

var navUrl = "/inscor/"+compName+"App.app"+"?releaseId="+releaseId;
every thing is working as expected. But default SF header is not coming. I mean salesforce tab options which comes by default. I have implemented "force:appHostable" for both component and app but it's still not coming. can an one please guide me one this.
Thnaks,
Manohar

Hi,

i cant figre out how to use aggregate query for this.

i need to count assigned lead to a user. i believe assignment is judged by the ownerId. 

i need to do this using aggregate query.. 

i new to get map <userId, count(assinedLead)>, how do i get this.?

please let  me know how to do this,  i never used aggrregate query before.

Thnaks,

Manohar

Hi Team,

i am trying to get map<user, List<lead>>(), List of lead is records created by the user. I think query for getting related list will not work here.

How do i achieve this.

Thanks,

Manohar

Hi Everyone,

i have a batch class which insets Results__c records. i Wrote a test class for that, which is working fine and also able to debug inserted record id.

but when i am putting assert(insertedResultRecls.size()>0), its falling and only covers some line on from the top.

when i remove assert statement and try to qury  Results__c records, its showing empty. but in debug its creating record.

And when i try to see if CronTrigger is fired or not, it was not fired. 

batch1 obj = new batch1();
        Test.startTest();
        Id batchJobId = DataBase.executeBatch(obj); 
        List<Result__c> assls = new List<Result__c>();
        system.debug('assls.size'+assls.size());  // coming 0
        //system.assert(assls.size()>0);
        Test.stopTest();
        system.debug('batchJobId :'+batchJobId);
        List<CronTrigger> cronTrigger  = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE Id = :batchJobId];  // not returning any value
        //System.assertEquals(cronTrigger.TimesTriggered, 1);
        system.debug('cronTrigger :'+cronTrigger[0]);
        system.debug('cronTrigger.TimesTriggered :'+cronTrigger[0].TimesTriggered);


Any help would be appreciated.

Thanks

Manohar 

Hi Everyone,

i have a list of records which fields i am using to create, one parent record and one child record.i have one list for both parent and child.

i am inserting those list outside the loop. Now i have to set relationship between those. i cant do this inside loop because its not inserted yet.

Not able to figure out how do i do this.

for(rolinesDetails rold : rols){ 
                      Repair_Order_Line__c rol = new     Repair_Order_Line__c();
                      rol.Quantity_to_Repair__c = rold.Quantity_Accepted;
                      rol.Created_From_ROL__c = true;
                      rol.Original_Inventory_Line__c =  ?? // how do i put inv line id here 
                      rolls.add(rol);
                      
                      Inventory_Line__c il2 = new Inventory_Line__c();
                      il2.Acquisition_Cost__c = rold.roline.Estimated_Repair_Cost__c;
                      il2.Serial_Number__c = rold.Serial_Number;
                      invlist.add(il2);
                    
        }
insert invlist;

insert rolls;
its seems simple but cant figure out the solution. And i also need rolinesDetails fields value for creating both records.

 RepairOrderLine is child and  InventoryLine is parent. Thanks in advance.

Thnaks,

Manohar

  

Hi All,

How can we add more fields in the lookup search view. In classic we can go to search layout -->> lookup dialog. I changed in classic but its not showing more columns in lightning view. Is this possible in lightning view.? 

Thanks,

Manohar 

Hi Everyone,

I have a outputField which is uder repeat component. I have inlineEditSupport for inline editing. Now i made a html buttton on the top, my requirement is button should be dislayed only in inline edit mode.

i made a javascript fuction to display the button.

<script>
    	function showSave() {
    		alert('##');
    		document.getElementById('saveButton').style.display ="block";
    	}
    </script>
but i am not sure how to call this on double click for outputField.

i tried putting actionSupport in the outputField, but i am not sure.

Any help would be appreciated.

Thanks,

Manohar

 

Hi All,

i have a custom button on opportunity to create case.Our requirement is that one opportunity should be associated with one case.I made one url field on opportunity to store case url.Now the problem i am facing is how do i put hyperlink in my Error message so that user can go to the associated case if any case is already linked with opportunity.

I am using one page in the middle.This page calls the New url for created case.And updating the Field of the opportunity.I am using apex pageMessages tag on the page.Its working but i am not able to show hyperlink to the related case.

if(o1[0].Related_Case__c == null) {
				o1[0].Related_Case__c = hostVal+'/'+c1.id;
        		system.debug('##o1'+o1);
        		update o1;
        		PageReference p1 = new PageReference('/'+c1.id);
            	system.debug('###p1'+p1);
            	return p1;
			}
			else{
				
			String link = '<a href="https://cs87.salesforce.com/'+o1[0].Related_Case__c+'></a>';
 				ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'record already there'+ link));
				
				return null;
				
			}
 

Any help will be appreciated.

Thanks,

Manohar

I have a page which which shows fields of case in better ui. Now I have to create a button on opp named create case. After clicking create case it should create a case  with some similar fields on opportunity and show the same page. How can i do this??

Any help would be apprecitaed.Please let me know if anything is unclear.

Thanks,

Manohar

Hi All, i need to track a custom field fee on a case object.My goal is when i click on this fee it should disply the all previous values and the user who changged it.I enable the chatter feed for this field.What object do i have to query to get the details.How can i do this?Any help would be appreciated.

Thanks,

Manohar

Hi All,
Need a help with integrating xero invoice through Breadwinner app.I have installed the breadwinner app .i want to synch a custom object records to xero incoice.when a record is created it will synch to zero invoice using breadwinner app.Any help or any document  that i can go through.
Any help would be appriciated.

Thanks Manohar

Hi, i have a inputText and outputText in the a table cell which is rendering according to the button edit and save.In the table call i also have datefield and picklist and one InputTextArea. In the output mode its looking well but when i click edit table height and width are getting increased.And this looks bad.How do i fix width and height of the <td> so it looks same for the inputText and outputText?

Any help would be appriciated.

Thanks

Manohar 

Hi All,

I am having problem with verifing this module.Its very simple but i am not able to verify this.
Module:

Create an Apex class that returns an array (or list) of formatted strings ('Test 0', 'Test 1', ...). The length of the array is determined by an integer parameter.
The Apex class must be called 'StringArrayTest' and be in the public scope.
The Apex class must have a public static method called 'generateStringArray'.
The 'generateStringArray' method must return an array (or list) of strings. Each string must have a value in the format 'Test n' where n is the index of the current string in the array. The number of returned strings is specified by the integer parameter to the 'generateStringArray' method.
 

public class StringArrayTest {
    public Static List<string> generateStringArray(Integer n){
        integer i=1;
        List<String> rtn = new List<String>();
        for(i =1;i<=n;i++){
        rtn.add('\'Test '+i+'\'');
        }
        return rtn;
    }
}

Hi All,

I have a map Map<String, List<QuoteLineItem>>(). In key i am storing product2 name and in value its related lineItem for an quote.Its working fine and i am using this in a page.There is another object name Index_Order__c which has a lookup relationship with product2 and has a number field called Index.I want to rearrange the map based on the index. i did something like this to reslove this..

List<Index_Order__c> dup = [select Products,Index__c from Index_Order__c where Products IN :oldMap.keySet() order by Index__c];
        system.debug('###dup '+dup );
Map<String, List<QuoteLineItem>> newMap = new Map<String, List<QuoteLineItem>>();
        for(Index_Order__c p1:dup) {
            newMap.put(p1.Products,oldMap.get(p1.Products));
        }
        system.debug('###newMap'+neMap);
 

 but in debug map order is changged.I assume Map doesnot store order.Pls help me how to get resolve this...

Hi All,

i am trying to upload my files to onedrive.when i try to get the authentication code by calling a url in my get method but coming Status=OK, StatusCode=200.And in the body i am getting an html.pls help any help would be appreciated.And when i put the url in the body it works perfectly.

url i need to call:   https://login.live.com/oauth20_authorize.srf?client_id=Clientkey&scope=wl.signin wl.offline_access onedrive.readwrite&response_type=code&redirect_uri=https://ascmanohar-developer-edition.ap2.force.com/Redirect

my code :

public void GetCode(){
	      http h = new http();
	      httpRequest req = new httpRequest();
	      String Clientkey = EncodingUtil.urlEncode(key,'UTF-8');
             req.setHeader('Content-type', 'application/x-www-form-urlencoded');
	      req.setMethod('GET');
	      string str1 ='wl.signin wl.offline_access onedrive.readwrite';
	      string str2 = EncodingUtil.urlEncode(str1,'UTF-8');
	      
	      string str ='https://login.live.com/oauth20_authorize.srf?client_id='+Clientkey+'&scope='+str2+'&response_type=code&redirect_uri='+redirect_uri;
	      //str = EncodingUtil.urlEncode(str,'UTF-8');
	      system.debug('@@str'+str);
	      req.setEndPoint(str);
	      httpResponse res = h.send(req);
	      system.debug('##res'+res);  
	      system.debug('######'+res.getBody());
	      system.debug('##getlocation##'+res.getHeader('Location'));
      }
 

 

Hi All,

i have been trying to upload files to onedrive.its working when i paste the url in the browser for getting the authorization code but when i try to get it in the http get call its giving me 302 response code and in the location header its showing error=invalid_scope&error_description=The  provided  value  for  the  input  parameter  'scope'  is  not  valid.  The  scope  'wl.signi  nwl.offline_access  onedrive.readwrite'  does  not  exist.i am new in webservices so any help would be appreciated.

url i need to call:  https://login.live.com/oauth20_authorize.srf?client_id=xxxxxxx&scope=wl.signin wl.offline_access onedrive.readwrite
  &response_type=code&redirect_uri=https://xxxxxxxxxxxxxxxxxx.force.com/Redirect

my code 

public void GetCode(){
	      http h = new http();
	      httpRequest req = new httpRequest();
	    String Clientkey = EncodingUtil.urlEncode(key,'UTF-8');  
	      req.setMethod('GET');
	      string str1 ='wl.signi nwl.offline_access onedrive.readwrite';
	      string str2 = EncodingUtil.urlEncode(str1,'UTF-8');
	      string str ='https://login.live.com/oauth20_authorize.srf?client_id='+Clientkey+'&scope='+str2+'&response_type=code&redirect_uri='+redirect_uri;
	      system.debug('@@str'+str);
	      req.setEndPoint(str);
	      httpResponse res = h.send(req);
	      system.debug('##res'+res);  
	      system.debug('######'+res.getBody());
	      system.debug('##getlocation##'+res.getHeader('Location'));
      }

hi i am having trouble with calling onedrive api.here is my code,i dont understand how to use boundary in this.i am a newbie with api and going with the onedrive documentation.Any help would be appreciated.thanks

public void uploadFile(string accessToken){
set<id> allids = new set<id>();
allids.add('00Q2800000Fwl1b');
List<Attachment> content = [Select Id, Name, ContentType, BodyLength, Body, CreatedById, Description From Attachment Where ParentId IN :allids limit 1];
system.debug('@@content'+content);
httpRequest req = new httpRequest();
req.setEndPoint('https://apis.live.net/v5.0/me/skydrive/files?access_token='+accessToken);
req.setHeader('Content-Disposition', 'form-data; name="file"; filename="content[0].Name"');
req.setHeader('Content-Type', 'multipart/form-data; boundary=A300x');
//req.setLength('Content-Length',string.valueOf(content[0].BodyLength));
string Body = string.valueOf(content[0].Body); req.setBody(Body);
req.setHeader('Content-Length',string.valueOf(content[0].BodyLength));
req.setCompressed(true); req.setMethod('POST');
HttpResponse res = null;
http h= new Http();
res= h.send(req); system.debug('@@@@'+res);
System.debug('---------------------'+res.getbody());
}

error in the debug:

"error": { "code": "request_body_invalid", "message": "The request entity body for multipart form-data POST isn't valid. The expected format is:\u000d\u000a--[boundary]\u000d\u000aContent-Disposition: form-data; name=\"file\"; filename=\"[FileName]\"\u000d\u000aContent-Type: application/octet-stream\u000d\u000a[CR][LF]\u000d\u000a[file contents]\u000d\u000a--[boundary]--[CR][LF]" }

 

hi... i have seven sets of string and i need to extract values which are same in all seven sets. i tried using for loop but its giving me cpu time limit exceed.Any help would be appreciated.
Thanks

Hi Team,

i am trying to get map<user, List<lead>>(), List of lead is records created by the user. I think query for getting related list will not work here.

How do i achieve this.

Thanks,

Manohar

Hi ALL,

I have a requirement where I have to display a record with a different color based on the picklist value selected.

I have created a custom object called "CaseComments"  Picklist field name "visible to" which has "Internal" and "external" as value, If I choose Internal the record should be in Blue color likewise if I choose External the record should be in Green color.

Thanks in advance.

 
Hi Folks,
My recordsetVar is not displaying records even the object is having records in my Org.
Please find the peiece of code below and corresponding UI

<apex:page standardController="Account" recordSetVar="records" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!records}" var="r">
    <apex:column headerValue="Name" value="{!r.Name}"/>
    <apex:column headerValue="Phone" value="{!r.Phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form> </apex:page>

User-added image

Regards
Rama
 
How can we get the note related to a particular task object using SOQL. i have a requirement like there is a note on task, whenever i tried to create new note for the same task it has to append with old note values.
User-added image 
Am the system admin, I created free developer edition org with my email address but now I changed the network location, So when I tried to login showing invalid passoword and When I tried to RESET the passowod getting mail as  "We recently received a request to reset the Salesforce password for the username chandra@teqforcesolutions.com.For security reasons, your Salesforce administrator hasn’t approved logging in or resetting your password from the network location you used. Try logging in again by connecting to an approved network location and logging in with your existing password. If you still have issues, reset your password from that approved location.
If you didn't ask for your password to be reset, contact your Salesforce administrator."

I tried to reach support team they are mailing me the same steps and they are asking me to file a case, Hell man am unable to login to org they are asking to file a case and we cannot file a case from free developer org.

So anyone has solution please help me out, I have implemented lot of logics inthat org so I cannot afford to leave it 

so please please help me out inthis  
Hi,
  
  Below code works as expected by passing account id it will return the top account id only issue I see in below code is query is inside the while loop is there any other way to fix this issue and make the code bulkify.
public static String GetTopLevleElement(Id objId ){
        Boolean topLevelParent = false;
        if( objId <> null){
        while ( !topLevelParent ) {
            Account a = [ Select Id, ParentId From Account where Id = :objId limit 1 ];
            if ( a.ParentID != null ) {
                objId = a.ParentID;
            }
            else {
                topLevelParent = true;
            }
        }
         }
        return objId ;
    }

Thanks
Sudhir
  
Hello,

I have a trigger that is updating a value on a parent record.
The trigger run on the custom object "Cost_line_item__c" and updates value on the parent opportunity.

I would like this trigger to run only for a specific record type id of the opportunity (so, the parent object).

My trigger (working) is:
Trigger UpdateOpportunityBV on Cost_line_item__c(After Insert, After Update, After Delete, After UnDelete){
    
    List<ID> opportunityIds = New List<ID>();
	List<ID> mylistIds = New List<ID>();
    
    If(Trigger.IsInsert || Trigger.IsUpdate || Trigger.IsUnDelete){
        For(Cost_line_item__c oli: Trigger.New){
            if(oli.Opportunity__c  != null){
                opportunityIds.add(oli.Opportunity__c);
				mylistIds.add(oli.Id);
            }  
        }
    }
    If(Trigger.IsDelete){
        For(Cost_line_item__c con: Trigger.Old){
            opportunityIds.add(con.Opportunity__c);
			mylistIds.add(con.Id);
        }
    }
     
    List<opportunity> opportunityListToUpdate = New List<opportunity>();
    Decimal RollupAmount = 1;
    For(Opportunity opt: [Select Id, Number_of_beneficiaries__c, (Select ID, Value__c FROM Cost_line_items__r WHERE Used_for_BV_calculation__c=true) FROM Opportunity WHERE ID = :opportunityIds]){
		for(Cost_line_item__c con:opt.Cost_line_items__r){
			RollupAmount = RollupAmount * con.Value__c;
		}
		opt.tech_cost_line_calculation__c = RollupAmount;
        opt.Amount = RollupAmount * opt.Number_of_beneficiaries__c;
		opportunityListToUpdate.add(opt);
    }
     
     
    try{
        Update opportunityListToUpdate;
    }
     Catch(Exception E){
        System.Debug('Error Message: ' + e.getMessage());
    }
}
I tried to replace the line 
if(oli.Opportunity__c  != null){
By
if(oli.Opportunity__c  != null && oli.Opportunity__r.RecordTypeid=='0121r0000003Qzk')
But it doesn't work (nothing happens).

Any suggestions?
Hi 
I am doing Superbadge Advanced Apex Specialist. I have completed 7 steps successfully. I am doing development in developer console. 
When I am clicking on check challenge on step 8 I am getting below error
User-added image

As all other chalenges are already completed how can i fix the issue because i am unable to retake those steps again (I am not getting any option to check chalange for completed chalenges). I am also not having previous code as I am doing development in developer console.

I am ready to retake all changes again but how can I do it without creating other trailhead account.

In select field only Changing Semicolon from Multi-Select Picklist values to a Comma
not in next field


User-added image
  • April 04, 2018
  • Like
  • 0
Hi All,

Urgent help Needed!!
I need your help since i am new to salesforce.

Actually the issue is that i have written one trigger to validate the duplicate record creation for a perticular object but it is throwing the validation even when you are trying to edit the existing record.

Kindly sugest me the solution or please guide me if it is a valid scenario.

The trigger which i have written is
trigger duplicat on Ticket__c(before insert,before update)
 {
    list<string> cust = new list<string>();
    list<string> usernme =new list<string>();
    list<string> email= new list<string>();

for(Ticket__c a:Trigger.new)
    {
    cust.add(a.Customer);
   usernme.add(a.username);
    email.add(a.email-id);

    }

List<Work_Order_Rate__c> WOR =  List<Ticket__c> tickt1 =[select User_Name__c,Customer__c,Start_Date__c, End_Date__c from Ticket__c where User_Name__c=:usernme and Customer__c=:a.cust];

if(WOR.size()>0)   
for(Ticket__c a:Trigger.new)
        {
        for(Ticket__c b:WOR )
               {                
                 if(b.Start_Date__c  tickt1.Start_Date__c || b.Start_Date__c <=tickt1 .End_Date__c ||
                b.End_Date__c >=tickt1 .Start_Date__c || b.End_Date__c <=tickt1 .End_Date__c )

                a.adderror('You cannot create a duplicate Ticket.');
                }
        }
}

Regards,
Rohan
Hi everyone, 

I receive a requirement from clients where they wanted to track the Turn around time for approval processes.

We have approval processes for Case object and we want to calculate something like this : 

Turn Around Time = Time when a case is approved - Time when a case is submitted for approval

Any suggestion? 
So this is my Battch class and Test class.. but it only have 45%  coverage. How to make it 100%?
global class AwesomeCBBatch implements Database.Batchable<sObject>
{
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        Decimal amt = 500;
	String query = 'SELECT Id, Contact__c, Amount FROM Opportunity WHERE Contact__c != null AND Amount >=: amt';
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, List<Opportunity> scope)
    {
        Map<Id, Contact> conts = new Map<Id, Contact>();
        for ( Opportunity opp : scope)
        {
            if(!conts.containsKey(opp.Contact__c) {
            conts.put(opp.Contact__c, new Contact(Id = opp.Contact__c, Awesome__c = true));
	    }
        }
        update conts.values();
    } 

    global void finish(Database.BatchableContext BC)
    {

    }

}
 
@isTest

public class TestAwesomeCBBatch {
    static testMethod void testAwesomeCBBatch() {
		
        Contact con = new Contact();
        con.FirstName = 'Test';
        con.LastName = 'Contact';
        con.Awesome__c = false;
        
        List<Opportunity> newopp = new List<Opportunity>();
        for (integer i = 0; i < 200; i++) {
            Opportunity o = new Opportunity();
            o.Name = 'TestOpp';
            o.Contact__c = con.Id;
            o.Amount = 600;
            o.CloseDate = Date.today();
            o.StageName = 'Prospecting';
            newopp.add(o);
        }
        insert newopp;
        
        Test.startTest();
        AwesomeCBBatch b = new AwesomeCBBatch();
        Database.executeBatch(b);
        Test.stopTest();
    }
}
Hi Guys,
I write one time apex:image it will show in all pages. So i used static resource but it didn't come and often i had to write apex:image. I tried whatever examples in google. So please try in your org and help me out this problem.

Static Resource:
<style type="text/css" media="print">
div.header {
position: running(header);
}
@page
{
margin-top: -0.2in;
margin-left:-0.1in;
margin-right:-0.1in;
@top-center
{ content: element(header);
background-image: url('{!$Resource.Con_Header}');
}
}
</style>