• cher
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 7
    Replies
HI,

I have a custom button "Remove from Territory", which when clicked deletes data, I want the user to get a promopt asking "Are you sure you want to RemoveFromTerritory", if the user clicks Yes only then the action should be executed. Thanks in advance.. 

VF Page Code:-


<apex:page standardcontroller="Account" extensions="RemoveFromTerritory" action="{!deleteterritory}">   

</apex:page>


Controller Code:-

global class RemoveFromTerritory {

public static List<UserTerritory> UserList{get;set;}

public RemoveFromTerritory (ApexPages.StandardController cont){
   
UserList=new List<UserTerritory>();
       
   }
  
  
  // public String u {get; set;}

//u = Userinfo.getUserId();

String UserId=Userinfo.getUserId();

static pagereference movetonext()
{


pagereference pageref= new pagereference('/servlet/servlet.Integration?lid=01rA0000000RGei&ic=1');

pageref.setRedirect(true);

return pageref;
}

  webservice static void deleteterritory(id accountid){
  
   /*if(apexpages.currentpage().getParameters().get('id')!=null)
       accountid=apexpages.currentpage().getParameters().get('id');*/
     
    /*    system.debug('@@@'+accountid);
        Account acc=[select id from Account where id=:accountid];
       
           
        UserList=[Select UserId,TerritoryId from UserTerritory where UserId=:Userinfo.getUserId()];
       
        //List<Group> GroupList=new List<Group>([Select Id from Group
            //                                where RelatedId =:UserList.TerritoryId]);
           
           
            Set<Id> TerritoryIds=new Set<Id>();
           
           
            for(UserTerritory ust: UserList){
               
                TerritoryIds.add(ust.TerritoryId);
               
               
            }
           
            List<Group> GroupList=[Select Id from Group
                                                   where RelatedId IN:TerritoryIds
                                                   and Type='Territory'];
                                                  
            Set<Id> GroupIds=new set<Id>();                                   
                                                  
            for(Group g: GroupList){
               
                 GroupIds.add(g.id);
                       
            }                                     
               
               
        AccountShare AccSh=[Select Id from AccountShare where UserorGroupId IN: GroupIds and AccountId=:acc.id];
                                                  
            ///AccountShare AccSh= [Select Id from AccountShare where UserorGroupId=:GroupList];
           
            delete AccSh;
           
              movetonext();    */
    }
   
   
   
    public pagereference deleteterritory(){
     
      String accountid;
     
      accountid=apexpages.currentpage().getParameters().get('id');
     
      system.debug('@@@'+accountid);
        Account acc=[select id from Account where id=:accountid];
       
           
        UserList=[Select UserId,TerritoryId from UserTerritory where UserId=:Userinfo.getUserId()];
       
        //List<Group> GroupList=new List<Group>([Select Id from Group
            //                                where RelatedId =:UserList.TerritoryId]);
           
           
            Set<Id> TerritoryIds=new Set<Id>();
           
           
            for(UserTerritory ust: UserList){
               
                TerritoryIds.add(ust.TerritoryId);
               
               
            }
           
            List<Group> GroupList=[Select Id from Group
                                                   where RelatedId IN:TerritoryIds
                                                   and Type='Territory'];
                                                  
            Set<Id> GroupIds=new set<Id>();                                   
                                                  
            for(Group g: GroupList){
               
                 GroupIds.add(g.id);
                       
            }                                     
               
               
        AccountShare AccSh=[Select Id from AccountShare where UserorGroupId IN: GroupIds and AccountId=:acc.id];
                                                  
            ///AccountShare AccSh= [Select Id from AccountShare where UserorGroupId=:GroupList];
           
            delete AccSh;
           
            pagereference pageref= new pagereference('/servlet/servlet.Integration?lid=01rA0000000RGei&ic=1');

pageref.setRedirect(true);

return pageref;
    }
}


  • July 22, 2014
  • Like
  • 0
Hi, 

I am invoking a delete action from a visualforce button by invoking JavaScript which would delete the records from the AccountShare object. I also want the page to be redirected to the Account List view page after the delete action is completed. The delete action is working perfectly but the page redirection is not happening. 

 Below is the  code:-

Javascript code:-

{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}

var r = confirm("Are you sure you want delete?");
if(r == true)
{
sforce.apex.execute("RemoveFromTerritory","deleteterritory",{accountid:"{!Account.Id}"});

}


Controller Code:-

global class RemoveFromTerritory {



public static List<UserTerritory> UserList{get;set;}


public RemoveFromTerritory (ApexPages.StandardController cont){
   
UserList=new List<UserTerritory>();
       
   }
  
  
  // public String u {get; set;}

//u = Userinfo.getUserId();

String UserId=Userinfo.getUserId();

static pagereference movetonext()
{


pagereference pageref= new pagereference('/servlet/servlet.Integration?lid=01rA0000000RGei&ic=1');

pageref.setRedirect(true);

return pageref;
}
   webservice static void deleteterritory(id accountid){
  
   /*if(apexpages.currentpage().getParameters().get('id')!=null)
       accountid=apexpages.currentpage().getParameters().get('id');*/
     
        system.debug('@@@'+accountid);
        Account acc=[select id from Account where id=:accountid];
       
           
        UserList=[Select UserId,TerritoryId from UserTerritory where UserId=:Userinfo.getUserId()];
       
        //List<Group> GroupList=new List<Group>([Select Id from Group
            //                                where RelatedId =:UserList.TerritoryId]);
           
           
            Set<Id> TerritoryIds=new Set<Id>();
           
           
            for(UserTerritory ust: UserList){
               
                TerritoryIds.add(ust.TerritoryId);
               
               
            }
           
            List<Group> GroupList=[Select Id from Group
                                                   where RelatedId IN:TerritoryIds
                                                   and Type='Territory'];
                                                  
            Set<Id> GroupIds=new set<Id>();                                   
                                                  
            for(Group g: GroupList){
               
                 GroupIds.add(g.id);
                       
            }                                     
               
               
        AccountShare AccSh=[Select Id from AccountShare where UserorGroupId IN: GroupIds and AccountId=:acc.id];
                                                  
            ///AccountShare AccSh= [Select Id from AccountShare where UserorGroupId=:GroupList];
           
            delete AccSh;
           
              movetonext();
           
           
               

       
               
    }


}


VF Page code:-

<apex:page standardcontroller="Account" extensions="RemoveFromTerritory">

<script>
function confirmDelete() {
var doDelete = confirm('Are you sure?');
return doDelete;
}
</script>

    <apex:form >
   
    <apex:commandButton action="{!deleteterritory}" value="Remove From Territory"/>  
   
    </apex:form>

</apex:page>
  • July 18, 2014
  • Like
  • 0
Hi, 

I am executing the apex job from a detail page button below is the code :

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
var url = parent.location.href;
var scr="updateSalesTeamValuesonKeyMessage updatekeys = new updateSalesTeamValuesonKeyMessage(); " +
" database.executebatch(updatekeys); ";
var result = sforce.apex.executeAnonymous(scr);


I want the user to get a message stating "the reqeusted job as completed" after successful execution of the apex job. Let me know if there is a way to do this. 
  • June 11, 2014
  • Like
  • 0
Hi


I have child object "Relationship" related to Account. There is field on the Account "Relationship__c", in this field i want to auto populate concatenated values of distinct createdbyIds for each relationship record. 

For instace, if the createdbyids for relationship records pertaining to an account "A" are A1, B1, C1. Then the Relationship field on the Account should be populated with A1;B1;C1. 

Let me know if this is possible by apex triiger.
  • May 18, 2014
  • Like
  • 0

Hi

 

i am trying to migrate package from sandbox to production. I would like to know if I do the migration with eclipse if the FLS will come through?

 

Thanks

  • February 10, 2012
  • Like
  • 0

Hi 

 

 In sandbox i am want to deactivate an apex class, i am not seeing the status checkbox when i click edit link of the class. Is this normal? Is there any other way in which in can deactivate the classes?

 

Thanks

  • February 08, 2012
  • Like
  • 0

I executed the following related soql query in salesforce workbench:

select ACT_STATUS_ABT__C, ACCOUNT__R.Name from ACT_STATUS__C where ACT_STATUS_ABT__C != NULL

Here ACT_STATUS__C is the child object of the account (i.e there is a master detail relationship to the account). 

 

This query is working perfectly in the Apex Explorer, But When I execute the same query in the salesforce workbench I am getting the following error: 

 

Parent relationship queries are not allowed. 

 

What could be the reason? The API version of workbench I am using is 22.0

 

 

  • October 07, 2011
  • Like
  • 0
HI,

I have a custom button "Remove from Territory", which when clicked deletes data, I want the user to get a promopt asking "Are you sure you want to RemoveFromTerritory", if the user clicks Yes only then the action should be executed. Thanks in advance.. 

VF Page Code:-


<apex:page standardcontroller="Account" extensions="RemoveFromTerritory" action="{!deleteterritory}">   

</apex:page>


Controller Code:-

global class RemoveFromTerritory {

public static List<UserTerritory> UserList{get;set;}

public RemoveFromTerritory (ApexPages.StandardController cont){
   
UserList=new List<UserTerritory>();
       
   }
  
  
  // public String u {get; set;}

//u = Userinfo.getUserId();

String UserId=Userinfo.getUserId();

static pagereference movetonext()
{


pagereference pageref= new pagereference('/servlet/servlet.Integration?lid=01rA0000000RGei&ic=1');

pageref.setRedirect(true);

return pageref;
}

  webservice static void deleteterritory(id accountid){
  
   /*if(apexpages.currentpage().getParameters().get('id')!=null)
       accountid=apexpages.currentpage().getParameters().get('id');*/
     
    /*    system.debug('@@@'+accountid);
        Account acc=[select id from Account where id=:accountid];
       
           
        UserList=[Select UserId,TerritoryId from UserTerritory where UserId=:Userinfo.getUserId()];
       
        //List<Group> GroupList=new List<Group>([Select Id from Group
            //                                where RelatedId =:UserList.TerritoryId]);
           
           
            Set<Id> TerritoryIds=new Set<Id>();
           
           
            for(UserTerritory ust: UserList){
               
                TerritoryIds.add(ust.TerritoryId);
               
               
            }
           
            List<Group> GroupList=[Select Id from Group
                                                   where RelatedId IN:TerritoryIds
                                                   and Type='Territory'];
                                                  
            Set<Id> GroupIds=new set<Id>();                                   
                                                  
            for(Group g: GroupList){
               
                 GroupIds.add(g.id);
                       
            }                                     
               
               
        AccountShare AccSh=[Select Id from AccountShare where UserorGroupId IN: GroupIds and AccountId=:acc.id];
                                                  
            ///AccountShare AccSh= [Select Id from AccountShare where UserorGroupId=:GroupList];
           
            delete AccSh;
           
              movetonext();    */
    }
   
   
   
    public pagereference deleteterritory(){
     
      String accountid;
     
      accountid=apexpages.currentpage().getParameters().get('id');
     
      system.debug('@@@'+accountid);
        Account acc=[select id from Account where id=:accountid];
       
           
        UserList=[Select UserId,TerritoryId from UserTerritory where UserId=:Userinfo.getUserId()];
       
        //List<Group> GroupList=new List<Group>([Select Id from Group
            //                                where RelatedId =:UserList.TerritoryId]);
           
           
            Set<Id> TerritoryIds=new Set<Id>();
           
           
            for(UserTerritory ust: UserList){
               
                TerritoryIds.add(ust.TerritoryId);
               
               
            }
           
            List<Group> GroupList=[Select Id from Group
                                                   where RelatedId IN:TerritoryIds
                                                   and Type='Territory'];
                                                  
            Set<Id> GroupIds=new set<Id>();                                   
                                                  
            for(Group g: GroupList){
               
                 GroupIds.add(g.id);
                       
            }                                     
               
               
        AccountShare AccSh=[Select Id from AccountShare where UserorGroupId IN: GroupIds and AccountId=:acc.id];
                                                  
            ///AccountShare AccSh= [Select Id from AccountShare where UserorGroupId=:GroupList];
           
            delete AccSh;
           
            pagereference pageref= new pagereference('/servlet/servlet.Integration?lid=01rA0000000RGei&ic=1');

pageref.setRedirect(true);

return pageref;
    }
}


  • July 22, 2014
  • Like
  • 0
Hi


I have child object "Relationship" related to Account. There is field on the Account "Relationship__c", in this field i want to auto populate concatenated values of distinct createdbyIds for each relationship record. 

For instace, if the createdbyids for relationship records pertaining to an account "A" are A1, B1, C1. Then the Relationship field on the Account should be populated with A1;B1;C1. 

Let me know if this is possible by apex triiger.
  • May 18, 2014
  • Like
  • 0
Hi, everyone!

I'm trying to access to a web service written in Apex. It's very simple as follwing ;

|  global class MyHello {
|      webService static String getHello(String yourName) {
|          return 'Hello, ' + yourName + '!!';
|      }
|  }

I'm using axis-1.4, and I generate stubs with the following command.

|  java org.apache.axis.wsdl.WSDL2Java -a .\MyHello.xml

where MyHello.xml is gotten from Visualforce.com UI.

Then, I write the following client code ;

|  package com.sforce.soap.client;
|  import com.sforce.soap.schemas._class.MyHello.*;
|
|  public class MyHelloClient {
|      public static void main(String[] args) {
|         try {
|              MyHelloService mhs = new MyHelloServiceLocator();
|              MyHelloPortType mh = mhs.getMyHello();
|              System.out.println("GREETING : " + mh.getHello("FooBar"));
|         }
|          catch(Exception e){
|              e.printStackTrace();
|         }
|      }
|  }

This failes with following exception.

|  AxisFault
|   faultCode: {http://soap.sforce.com/schemas/class/MyHello}INVALID_SESSION_ID
|   faultSubcode:
|   faultString: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
|   faultActor:
|   faultNode:
|   faultDetail:
|      {http://xml.apache.org/axis/}stackTrace:INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session

"Quick Start" in "Force.com Web Services API Developer's Guide" shows me a sample program to login and set session id.
But I couldn't understand how to implement setting sessionId with the stubs of my custom web service.

If anyone know about this issue, please show me the right way.

thanks.

  • September 30, 2008
  • Like
  • 0

We are trying to integrate one of our Commerce Application with our Salesforce Instance and during the login call we receive the following error using C#/.NET.  However the login works through  console application however throws the above error through the .dll (compiled with the same code) which is called by our Commerce Application.

 

Exception : System.Web.Services.Protocols.SoapHeaderException: Required field/property SforceService.LoginScopeHeaderValue of SOAP header LoginScopeHeader was not set by the client prior to making the call.
at System.Web.Services.Protocols.SoapHeaderHandling.GetHeaderMembers(SoapHeaderCollection headers, Object target, SoapHeaderMapping[] mappings, SoapHeaderDirection direction, Boolean client)
at System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize(WebRequest request, String methodName, Object[] parameters)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at Mercury_SFAdapter.Sforce.SforceService.login(String username, String password)
at Mercury_SFAdapter.Mercury_SFAdapterSvc.login()

 

Further,  when we provide the organisationId, (as below) – (Commented in The Source Code Shared Below)

binding.LoginScopeHeaderValue = new Mercury_SFAdapter.Sforce.LoginScopeHeader();
binding.LoginScopeHeaderValue.organizationId = "Our Org ID";

the Exception changes to the one below:

 

Exception : System.Web.Services.Protocols.SoapException: INVALID_LOGIN: Invalid username or password, locked out or Self-Service portal is not enabled
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at Mercury_SFAdapter.Sforce.SforceService.login(String username, String password)
at Mercury_SFAdapter.Mercury_SFAdapterSvc.login()

 

The same username/Password works absolutely fine through the Web Interface and Console Application. We also tried to use the Security Token along with the Password but with no Luck.

 

The Source Code used is as Below:

 

 

private bool login()

{

binding = new Mercury_SFAdapter.Sforce.SforceService();

try

{

//execute the login placing the results

//in a LoginResult object

//binding.LoginScopeHeaderValue = new Mercury_SFAdapter.Sforce.LoginScopeHeader();

//binding.LoginScopeHeaderValue.organizationId = "00D500000007nEo";

Mercury_SFAdapter.Sforce.LoginResult loginResult = binding.login("username", "password");

if (!loginResult.passwordExpired)

{

binding.Url = loginResult.serverUrl;

//set the session id header for subsequent calls

binding.SessionHeaderValue = new Mercury_SFAdapter.Sforce.SessionHeader();

binding.SessionHeaderValue.sessionId = loginResult.sessionId;

return true;

}

else

{

QLogWrapper.m_staticLogger.logComment("Password is Expired");

}

}

catch (Exception ex)

{

QLogWrapper.m_staticLogger.logComment("Exception : " + ex);

}

//Login failed, report message then return false

//--------Console.WriteLine("Login failed with message: " + ex.Message);

return false;

}


 

 

Request some immediate assistance on this.

 

Thank you,

Manish K Dhupar

Setup>Customize>Integrate>API contains the following instructions and  a link to download a WSDL file

Salesforce's WSDL allows you to easily integrate Salesforce with your applications, and to build new applications that work with Salesforce. To get started, download a WSDL file to a place accessible to your development environment.

How/where do I save the webpage that is returned after clicking the link?

Finky
  • November 15, 2007
  • Like
  • 0