• Butesh Singla
  • NEWBIE
  • 5 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 9
    Replies
Anyone done ordering rows by drag and drop using lwc components. If yes can you please help.
I need to remove the 1st column from the lightning table which is the row number but not able to do it.
User-added image


My .cmp looks as follows
 
<aura:attribute name="recordId" type="Id" />
<aura:attribute name="Order" type="Order__c" />
<aura:attribute name="OrderLines" type="Otter_FFA_Order_Line_Item__c" />
<aura:attribute name="Columns" type="List" />

<aura:handler name="init" value="{!this}" action="{!c.myAction}" />

<force:recordData aura:id="OrderRecord" recordId="{!v.recordId}" targetFields="{!v.Order}" layoutType="FULL" />


<lightning:card iconName="standard:contact" title="{! 'Order Items List for ' + v.Order.Otter_FFA_Order__c}">
    <!-- Order Line list goes here -->
        <lightning:datatable data="{! v.OrderLines }" columns="{! v.Columns }"  keyField="Id"/>

</lightning:card>

And .js is as below
({ myAction : function(component, event, helper) {

    component.set("v.Columns", [
        {label:"#", initialWidth: 20, fieldName:"Otter_FFA_Ln__c", type:"number"},
        {label:"Item", initialWidth:80, fieldName:"Product_Name__c", type:"text"},
        {label:"Description", initialWidth: 110, fieldName:"Description_1_and_2__c", type:"text"},
        {label:"QTY", initialWidth: 70, fieldName:"Otter_FFA_Quantity__c", type:"number",editable: true},
    {label:"Net Price", initialWidth: 70, fieldName:"Otter_FFA_Net_Price__c", type:"number"},
        {label:"Add Disc%", initialWidth: 90, fieldName:"Otter_FFA_User_Discount__c", type:"number",editable: true},
        {label:"Order Price", initialWidth: 70, fieldName:"Otter_FFA_Applied_Net_Price__c", type:"number",editable: true},
        {label:"Total Before GST", initialWidth: 70, fieldName:"Otter_FFA_Total_Price__c", type:"number"}

    ]);
    var action = component.get("c.getOrderLines");

    action.setParams({
        recordId: component.get("v.recordId")
    });

    action.setCallback(this, function(OrderLines) {
        component.set("v.OrderLines", OrderLines.getReturnValue());
    });

    $A.enqueueAction(action);
}
})

with a stylesheet as below
.THIS .slds-th__action{ word-wrap: initial; font-weight: bold; font-size: 70% !important; }
 
Hi All,
When a new Account is created, create a new Contact that has the following data points:
First Name = “Info”
Last Name = “Default”
Email = “info@websitedomain.tld”
Only_Default_Contact = TRUE
When the Account has more than 1 Contact, update Only_Default_Contact to FALSE.
Hi everyone. 
Can you provide any example how can I implement drag and drop columns in <table> without external lib. I want use only pure JS and Lightning Component.
Thank for reply.
HI All, 
I am trying to download a Case Attachment and below is the query I use.
Query = getFetchDraftUrl() + "?q=" + URLEncoder.encode("SELECT Name,Body FROM Attachment WHERE Id = '"+ fileId + "'", "UTF-8");
But the response I get for Body is in URL 
" "attributes":{"type":"Attachment","url":"/services/data/v34.0/sobjects/Attachment/00P4D000000wkcZUAQ"},"Id":"00P4D000000wkcZUAQ","Name":"test 8.txt"} "

I am expecting the Base64 data. Is there anything wrong that I am doing? Can someone help me understand this?
Hello,
I am tring to connect java to salesforce by using rest api..

here i am attached the code,after running this code it throughs a exception 

Code:-

import java.io.InputStreamReader;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.params.HttpClientParams;
import org.json.JSONObject;
import org.json.JSONTokener;

public class  JavarestApi{
private static final String clientId="3MVG9d8..z.hDcPL3l_8qXSX5sPV_vOueBOIUnrKxsH0MQdtcD0r0H13mxvNTwXV4.mt8YX1unfFha68RuDor"; 
private static final String clientSecret="1958974945496795189";
private static final String redirectUrl="https://localhost:8443/RestTest/oauth/_callback";
private static  String tokenUrl="";
private static final String environment="https://login.salesforce.com";
private static final String username="***********@gmail.com";
private static final String password="*****************************************";                   //passwordsecurity token

private static  String accessToken="";
private static  String instanceUrl="";

public static void main(String ar[]){
System.out.println("----------getting a token---------");

tokenUrl=environment+"/services/oauth2/token";
System.out.println("tokenUrl    ........."+tokenUrl);
HttpClient httpclient=new HttpClient();
//httpclient.getParams().setParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, true);
httpclient.getParams().setParameter(HttpClientParams.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY);

PostMethod post=new PostMethod(tokenUrl);
post.addParameter("grant_type","password");
post.addParameter("client_id",clientId);
post.addParameter("client_secret",clientSecret);
post.addParameter("redirect_url",redirectUrl);
post.addParameter("username",username);
post.addParameter("password",password);

try{
httpclient.executeMethod(post);
JSONObject authResponse=new JSONObject(new JSONTokener (new InputStreamReader(post.getResponseBodyAsStream())));
System.out.println("Auth Response :-"+authResponse.toString(2));

accessToken=authResponse.getString("access_token");
instanceUrl=authResponse.getString("instance_url");

System.out.println("Got Access Token " +accessToken);
System.out.println("Got Instance Url " +instanceUrl);


new JavarestApi().createaccount(instanceUrl,accessToken);
}
catch(Exception e){
    System.out.println("Exception during Connect"+e);
}

}

private String createaccount(String instanceUrl,String accessToken) throws Exception{
    System.out.println("----------start account--------");
HttpClient httpclient=new HttpClient();
JSONObject account=new JSONObject();
String accountId="";

try{
account.put("Name", "Amol");
account.put("AccountNumber", "98123");

PostMethod post=new PostMethod(instanceUrl+"/services/data/v20.0/sobjects/Account/");
post.setRequestHeader("Authorization", "OAuth" +accessToken);
post.setRequestEntity(new StringRequestEntity(account.toString(),"application/x-www-form-urlencoded",null));

httpclient.executeMethod(post);
System.out.println("HTTP status"+post.getStatusCode()+"creating account\n\n");
 if(post.getStatusCode() == HttpStatus.SC_CREATED ){
     try{
         JSONObject response=new JSONObject(new JSONTokener (new InputStreamReader(post.getResponseBodyAsStream())));
         System.out.println("create response" + response.toString(2));
         if(response.getBoolean("success")){
             accountId=response.getString("id");
             
             System.out.println("new record id:-" +accountId+"\n\n");
         }
     }catch(Exception e){
         e.printStackTrace();
     }
 }


}
catch(Exception e){
    e.printStackTrace();
}
System.out.println("----------end account--------");
return accountId;
}

}



Exception :-

----------getting a token---------

tokenUrl    .........https://login.salesforce.com/services/oauth2/token
Auth Response :-{
  "access_token": "00D7F000001ZxXl!ARYAQBcTSXtZXdYDXFHlneUawyG9iqF6_dCTBPSbBCqrV6vSDPzzcNJesGFBS239x7p51xBAP4ZaqHOfgrmH7tZam2wTS3GX",
  "signature": "GFMgzpOtCxO2UuPBqGh2SHogWMdx0mk6J6X30goaFRU=",
  "instance_url": "https://ap5.salesforce.com",
  "id": "https://login.salesforce.com/id/00D7F000001ZxXlUAK/0057F000000qvkHQAQ",
  "token_type": "Bearer",
  "issued_at": "1503479401122"
}
Got Access Token 00D7F000001ZxXl!ARYAQBcTSXtZXdYDXFHlneUawyG9iqF6_dCTBPSbBCqrV6vSDPzzcNJesGFBS239x7p51xBAP4ZaqHOfgrmH7tZam2wTS3GX
Got Instance Url https://ap5.salesforce.com
----------start account--------
HTTP status401creating account


----------end account--------
Aug 23, 2017 5:09:59 AM org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge
WARNING: Unable to respond to any of these challenges: {token=Token}


$401unthorized http error

it not inserted the data into salesforce 


 
Hi,
Below is my code for the trigger for  duplicate prevention on the account . It works well, but if I have 50k records this impacts scalability and not feasible.
So please any one can help to code in better way.
thanks in advance.
trigger AccountDuplicate on Account (before insert) {
 List<Account> dup = new List<Account>();
 dup = [Select id, Name from Account];
 for(Account a:Trigger.New){
 for(Account a1:dup){
 if(a.Name==a1.Name){
 a.Name.addError('Name already Exist ');
 }
 }
 }   
 }
Hi All,

I am new to salesforce. I have an salesforce user access as system administrator and we have some communities in our org. I want to login to this community as community plus user not as salesforce user. How do i go head and add community user to my profile and login. Will there be a seperate login for Salesforce user and another one for community user. Kindly help.

Thanks!!

I'm using C# and SF REST API. I have no problems so far get-ing and inserting some custom data from SF (Accounts,etc..). But now a have to insert PDF attachment using REST API, and i'm stuck. I's  it even possible? And if it is how? Any help will be appreciated.