• k practice
  • NEWBIE
  • 20 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 23
    Replies
Hi,

function newDoc() {
            window.top.location.href ='http://www.google.com/inquiry?property='+{!urlpropertyname};
            alert({!urlpropertyname});
        }

<apex:commandbutton value="getURL" onclick="newDoc();"/>

help me..
Hi,
      trigger autoCreatOpp on Case (after insert, after update)
{
list<Opportunity> getOpp = new list<Opportunity>();
list<Opportunity> newOpp = new list<Opportunity>();

set<id> caseid = new set<id>();
for(Case newCase : Trigger.new)
{
if(newcase.status == 'Escalated')
caseid.add(newCase.id);
}

getOpp = [select id,recordtypeid,Orginating_Case__c  from Opportunity where recordtype.name='Professional_Service_Change_Order' and Orginating_Case__c =: caseid ];

for(Case c : [select id,status,casenumber,accountid,subject from case where id =: caseid ])
{
if(getOpp.size() == 0)
{
Opportunity opp = new Opportunity();
opp.name = c.accountid +'-'+ c.subject;
opp.accountid = c.accountid;
opp.recordtypeid='012j0000000WH2U';
opp.closedate = system.today()+30;
opp.stagename = 'Open';
opp.Orginating_Case__c = c.casenumber;
newOpp.add(opp);
}
}
insert newOpp;
}

help me...
Hi,
List < Task > listofTaskRelatedtoBusinessAccountContact = [SELECT Id,WhoId,Whatid FROM Task WHERE WhoId = : contactid];
List < Event > listofEventsRelatedtoBusinessAccountContact = [SELECT Id,WhoId,Whatid FROM Event WHERE WhoId = : contactid];

 for (Task iterateContactTask: listofTaskRelatedtoBusinessAccountContact) {
                  iterateContactTask.WhatId = pAccount.id;
            }
            for (Event iterateContactEvent: listofEventsRelatedtoBusinessAccountContact) {
              iterateContactEvent.WhatId = pAccount.id;
            }        
 try {
                update listofTaskRelatedtoBusinessAccountContact;
            } catch (Exception e) {}
            try {
                update listofEventsRelatedtoBusinessAccountContact;
            } catch (Exception e) {}

How to update Contact related Tasks and events To Personal account?

help me........
Hi,
Here i was getting Contact object Custom fields.If suppose one custom field is not there in below comparing object(Person object).How to avoid this custom fields and same fields how to update?
  for (Schema.SObjectField objField: Schema.getGlobalDescribe().get('Contact').getDescribe().fields.getMap().values()) {
                DescribeFieldResult fr = objField.getDescribe();
                if (fr.isUpdateable()) //isCreateable())
                {
                    if (fr.getName().endsWith('__c')) {
                        String str = fr.getName();
                        String contactcustomFields = str.replaceAll('__c', '__pc');
                        System.debug(contactcustomFields);
                        pAccount.put(contactcustomFields, Ocontact.get(str));
                        //update pAccount;
                        System.debug(pAccount.put(contactcustomFields, Ocontact.get(str)));
                    }
                
                }
            }

Help me.....
Hi,
I tried like below but its not working
BUTTON CODE:
----------
{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/26.0/apex.js")}
var result = sforce.apex.execute('MyClass', 'myMethod', {Accountid:'{!Account.Id}'});
Alert('More than one contact not allowed'+result);
Class:
======
 webService static String myMethod(ID Accountid) {
String BusinessAccountid = Businessaccount.id;
String Errorstring='More than one contact not allowed';
List<Contact> checkBusinessAccountContactList=[SELECT id FROM Contact WHERE Accountid = :BusinessAccountid];
                System.debug(checkBusinessAccountContactList);
                Account BusinessAccountrelatedContacts=new Account();
                if(checkBusinessAccountContactList.size() > 1)
                {
                   return Errorstring;
                }

}
help me..
Hi,
       Now i have accountid.Using this account id how to valuate account child records to contact?
after creating the new  account and contact record, evaluate the following child records:
> activities: reassign the name and related to fields (whichever may be populated, one, the other, or both) from the originating  account to the new contact.
Hi,
         for(Schema.SObjectField objField : Schema.getGlobalDescribe().get('Account').getDescribe().fields.getMap().values())
                     {
                       if(objField.getDescribe().getName().endsWith('__pc'))
                       {
                           String str=objField.getDescribe().getName();
                           String personaccountFields=str.replaceAll('__pc', '__c');
                           Ocontact.put(str, personaccountFields.get(str));
                       }
                     }

here i was getting readonly fields error .how to solve this error?
                
Hi,
       Mu date is Date startdate="09/22/2015";

How to display This date as O/p:-2015-09-22  

please help me...
Hi,
       I have a button in Account detail page like "Create Contact".When i click this button how to create contact with account name related account?
How to  create a new account with Record Type of “Business” using  Personal account  layout Button ?
Hi,

function newDoc() {
            window.top.location.href ='http://www.google.com/inquiry?property='+{!urlpropertyname};
            alert({!urlpropertyname});
        }

<apex:commandbutton value="getURL" onclick="newDoc();"/>

help me..
Hi,
      trigger autoCreatOpp on Case (after insert, after update)
{
list<Opportunity> getOpp = new list<Opportunity>();
list<Opportunity> newOpp = new list<Opportunity>();

set<id> caseid = new set<id>();
for(Case newCase : Trigger.new)
{
if(newcase.status == 'Escalated')
caseid.add(newCase.id);
}

getOpp = [select id,recordtypeid,Orginating_Case__c  from Opportunity where recordtype.name='Professional_Service_Change_Order' and Orginating_Case__c =: caseid ];

for(Case c : [select id,status,casenumber,accountid,subject from case where id =: caseid ])
{
if(getOpp.size() == 0)
{
Opportunity opp = new Opportunity();
opp.name = c.accountid +'-'+ c.subject;
opp.accountid = c.accountid;
opp.recordtypeid='012j0000000WH2U';
opp.closedate = system.today()+30;
opp.stagename = 'Open';
opp.Orginating_Case__c = c.casenumber;
newOpp.add(opp);
}
}
insert newOpp;
}

help me...
Hi,
List < Task > listofTaskRelatedtoBusinessAccountContact = [SELECT Id,WhoId,Whatid FROM Task WHERE WhoId = : contactid];
List < Event > listofEventsRelatedtoBusinessAccountContact = [SELECT Id,WhoId,Whatid FROM Event WHERE WhoId = : contactid];

 for (Task iterateContactTask: listofTaskRelatedtoBusinessAccountContact) {
                  iterateContactTask.WhatId = pAccount.id;
            }
            for (Event iterateContactEvent: listofEventsRelatedtoBusinessAccountContact) {
              iterateContactEvent.WhatId = pAccount.id;
            }        
 try {
                update listofTaskRelatedtoBusinessAccountContact;
            } catch (Exception e) {}
            try {
                update listofEventsRelatedtoBusinessAccountContact;
            } catch (Exception e) {}

How to update Contact related Tasks and events To Personal account?

help me........
Hi,
I tried like below but its not working
BUTTON CODE:
----------
{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/26.0/apex.js")}
var result = sforce.apex.execute('MyClass', 'myMethod', {Accountid:'{!Account.Id}'});
Alert('More than one contact not allowed'+result);
Class:
======
 webService static String myMethod(ID Accountid) {
String BusinessAccountid = Businessaccount.id;
String Errorstring='More than one contact not allowed';
List<Contact> checkBusinessAccountContactList=[SELECT id FROM Contact WHERE Accountid = :BusinessAccountid];
                System.debug(checkBusinessAccountContactList);
                Account BusinessAccountrelatedContacts=new Account();
                if(checkBusinessAccountContactList.size() > 1)
                {
                   return Errorstring;
                }

}
help me..
Hi,
         for(Schema.SObjectField objField : Schema.getGlobalDescribe().get('Account').getDescribe().fields.getMap().values())
                     {
                       if(objField.getDescribe().getName().endsWith('__pc'))
                       {
                           String str=objField.getDescribe().getName();
                           String personaccountFields=str.replaceAll('__pc', '__c');
                           Ocontact.put(str, personaccountFields.get(str));
                       }
                     }

here i was getting readonly fields error .how to solve this error?
                
Hi,
       Mu date is Date startdate="09/22/2015";

How to display This date as O/p:-2015-09-22  

please help me...

public class checksobjectprofiles
{

public List<SelectOption> ListOfUser {public get; private set; }

public String selecteduserId { get; set; }

public string searchresult;
public Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
public List <SelectOption> objectNames{public get; private set;}
public String selectedObject {get; set;}


public checksobjectprofiles ()
{
objectNames = initObjNames();
ListOfUser= initListOfUser();


}
private List<SelectOption> initObjNames()
{
List<SelectOption> objNames = new List<SelectOption>();
List<String> entities = new List<String>(schemaMap.keySet());
entities.sort();
objNames.add(new SelectOption( ' ' ,'---Select---'));
for(String name : entities)
{


objNames.add(new SelectOption(name,name));
}
return objNames;
}

private List<SelectOption> initListOfUser()
{
// String uid = UserInfo.getUserId();
List<User> thisUser = [select id, Username, profile.name from User where IsActive=true];
List<SelectOption> Ulist = new List<SelectOption>();
Ulist.add(new SelectOption( ' ' ,'---Select---'));
for(User u : thisuser )
{

Ulist.add(new SelectOption(u.Username ,u.username));
}
return Ulist ;
}

public void checkFields()
{

//fields.clear();
system.debug('$$$$$' + selectedObject);
list<string> lstFields = new list<string>();

list<string> sobjectfields = new list<string>();
Map <String, Schema.SObjectField> fieldMap = schemaMap.get(selectedObject).getDescribe().fields.getMap();
for(Schema.SObjectField sfield : fieldMap.Values())
{
schema.describefieldresult fieldresult = sfield.getDescribe();

lstFields.add(fieldresult.getName());
// system.debug('#######' + lstFields );
}

// system.debug('@@@@@@@@@@@@@@@@@@@'+selectedObject);

Map<String,Schema.SObjectType> gd = Schema.getGlobalDescribe();
Schema.DescribeSObjectResult r = gd.get(selectedObject).getDescribe();
String tempName = r.getName();
system.debug('*************'+tempname);
system.debug('selecteduserid'+selecteduserId);
system.debug('%%%%%%%%%%%%%%'+lstFields);

searchresult= 'select' + lstFields +'from' + 'tempName' + ' WHERE ' + ' Id =: selecteduserId ';
system.debug('*************'+searchresult);
System.runAs(searchresult)
{

if(searchresult.isUpdatable()) here i am getting error
{
// updatecheckbox=true;
}
if(searchresult.isdeletable()) here i am getting error
{
// updatecheckbox=true;
}
}

please help me frds.
}



}