• mixel007
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies

Hi everybody

I got a problem, trying to upload a picture profile photo, So I've been trying to do this in may ways, apperently you cannot do this with a simple query, you have to do this by the Chatter REST API, So here I got my problem, I'm trying to upload this by two ways.

- One, with javascript, calling background the Chatter REST API

- two, with the "ConnectApi" APi, it should work, but there is no way. I got this problem.

 

Error: TestController Compile Error: Dependent class is invalid and needs recompilation: ConnectApi.feeditempage: line 8, column 25: Dependent class is invalid and needs recompilation: ConnectApi.feeditem: line 6, column 20: Dependent class is invalid and needs recompilation: ConnectApi.actor: line 38, column 15: Dependent class is invalid and needs recompilation: ConnectApi.unauthenticateduser: line 2, column 50: Invalid class: actor at line 3 column 9

 

Can someone help me how to solve this ? Or maybe tell me how to do this task without using chatter rest API

 

Well,

i'm trying to do display all properties from any object from its ID in a component, I already have the next problem whe I try to update a sObject. So, Please I would like to know how to solve this. Please Help me.

My controller is...

................................

public with sharing class GenericObject {

public sObject gObject { get; set; }
public string id{ get; set; }
public List<string> describeList { get; set; }

public GenericObject()
{
describeList = new List<string>();

try{
id = Apexpages.currentPage().getParameters().get('id');
gObject = getObject(id);
}
catch(Exception e)
{
//myMsg = new Apexpages.Message(ApexPages.Severity.ERROR,'Error 111 : No Id was identify ');
//Apexpages.addMessage(myMsg);
// System.debug('Error 111 : No Id was identify ');
}
}

public sObject getObject(string idObject)
{
String s=idObject;
String id ='id';
String objectName = getObjectName(s);

Schema.SObjectType tobj = getObjectTypeFromId(idObject);

Map<String, Schema.SObjectField> allFields = tobj.getDescribe().fields.getMap();
String fieldToShowString='';

for(Schema.SObjectField df : allfields.values())
{
Schema.Describefieldresult res = df.getDescribe();
fieldToShowString+=res.getName()+',';
}

String soqlQuery = 'SELECT ' +fieldToShowString.subString(0,fieldToShowString.length()-1)
+' FROM '+objectName +' WHERE Id=\''+idObject+'\' LIMIT 1';

sObject L = DataBase.Query(soqlQuery);

/// Geting the describtion of an object
for(Schema.SObjectField df : allfields.values())
{
Schema.Describefieldresult res = df.getDescribe();
try{
string k=(string)L.get(res.getName());
if(k!=null)
{
// myMsg = new Apexpages.Message(ApexPages.Severity.ERROR,res.getName()+': '+k);
// Apexpages.addMessage(myMsg);
describeList.add(res.getName());
}
continue;
}catch(exception ex)
{

}
try{
Date k=(Date)L.get(res.getName());
if(k!=null)
{
// myMsg = new Apexpages.Message(ApexPages.Severity.ERROR,res.getName()+': '+k);
// Apexpages.addMessage(myMsg);
}
continue;
describeList.add(res.getName());
}catch(exception ex)
{

}
try{
Integer k=(Integer)L.get(res.getName());
if(k!=null)
{
// myMsg = new Apexpages.Message(ApexPages.Severity.ERROR,res.getName()+': '+k);
// Apexpages.addMessage(myMsg);
}
continue;
describeList.add(res.getName());
}catch(exception ex)
{

}
// describeList.add(res.getName());
}
return L;
}

private String getObjectName(string idObject)
{
String accId = idObject;
String keyCode = accId.subString(0,3);

Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
for(Schema.SObjectType objectInstance : gd.values())
{
if(objectInstance.getDescribe().getKeyPrefix() == keyCode)
{
//Process with the API name what you want
System.debug('Id is related to object: '+ objectInstance.getDescribe().getName());
// myMsg = new Apexpages.Message(ApexPages.Severity.ERROR,'Object you are displaying > '+objectInstance.getDescribe().getName());
// Apexpages.addMessage(myMsg);
return objectInstance.getDescribe().getName();
}
}
return null;
}

private Schema.SObjectType getObjectTypeFromId(String idObject)
{
return ((ID)idObject).getSObjectType();
}

public void save(){

update gObject;
}
}

 

------------------- And My component is

<apex:component controller="GenericObject">
<apex:form >
<apex:pageblock title="Generic Object" >
<apex:pageBlockSection title="Generic Object">
<apex:repeat value="{!describeList}" var="op">
<apex:outputField value="{!gObject[op]}" />
</apex:repeat>
<apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<!-- <apex:commandButton value="Edit" action="{!save}" id="editButton" /> -->
<apex:commandButton value="Save" action="{!save}" id="saveButton" />
<apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/>
</apex:pageBlockButtons>
</apex:pageblock>
</apex:form>
</apex:component>

--------------------- I try to Save Button Works !!! and i cannot do that.

I have the next error

 

Visualforce Error
 


System.LimitException: DML currently not allowed 

 

Class.GenericObject.save: line 120, column 1

 

Well,

i'm trying to do display all properties from any object from its ID in a component, I already have the next problem whe I try to update a sObject. So, Please I would like to know how to solve this. Please Help me.

My controller is...

................................

public with sharing class GenericObject {

public sObject gObject { get; set; }
public string id{ get; set; }
public List<string> describeList { get; set; }

public GenericObject()
{
describeList = new List<string>();

try{
id = Apexpages.currentPage().getParameters().get('id');
gObject = getObject(id);
}
catch(Exception e)
{
//myMsg = new Apexpages.Message(ApexPages.Severity.ERROR,'Error 111 : No Id was identify ');
//Apexpages.addMessage(myMsg);
// System.debug('Error 111 : No Id was identify ');
}
}

public sObject getObject(string idObject)
{
String s=idObject;
String id ='id';
String objectName = getObjectName(s);

Schema.SObjectType tobj = getObjectTypeFromId(idObject);

Map<String, Schema.SObjectField> allFields = tobj.getDescribe().fields.getMap();
String fieldToShowString='';

for(Schema.SObjectField df : allfields.values())
{
Schema.Describefieldresult res = df.getDescribe();
fieldToShowString+=res.getName()+',';
}

String soqlQuery = 'SELECT ' +fieldToShowString.subString(0,fieldToShowString.length()-1)
+' FROM '+objectName +' WHERE Id=\''+idObject+'\' LIMIT 1';

sObject L = DataBase.Query(soqlQuery);

/// Geting the describtion of an object
for(Schema.SObjectField df : allfields.values())
{
Schema.Describefieldresult res = df.getDescribe();
try{
string k=(string)L.get(res.getName());
if(k!=null)
{
// myMsg = new Apexpages.Message(ApexPages.Severity.ERROR,res.getName()+': '+k);
// Apexpages.addMessage(myMsg);
describeList.add(res.getName());
}
continue;
}catch(exception ex)
{

}
try{
Date k=(Date)L.get(res.getName());
if(k!=null)
{
// myMsg = new Apexpages.Message(ApexPages.Severity.ERROR,res.getName()+': '+k);
// Apexpages.addMessage(myMsg);
}
continue;
describeList.add(res.getName());
}catch(exception ex)
{

}
try{
Integer k=(Integer)L.get(res.getName());
if(k!=null)
{
// myMsg = new Apexpages.Message(ApexPages.Severity.ERROR,res.getName()+': '+k);
// Apexpages.addMessage(myMsg);
}
continue;
describeList.add(res.getName());
}catch(exception ex)
{

}
// describeList.add(res.getName());
}
return L;
}

private String getObjectName(string idObject)
{
String accId = idObject;
String keyCode = accId.subString(0,3);

Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
for(Schema.SObjectType objectInstance : gd.values())
{
if(objectInstance.getDescribe().getKeyPrefix() == keyCode)
{
//Process with the API name what you want
System.debug('Id is related to object: '+ objectInstance.getDescribe().getName());
// myMsg = new Apexpages.Message(ApexPages.Severity.ERROR,'Object you are displaying > '+objectInstance.getDescribe().getName());
// Apexpages.addMessage(myMsg);
return objectInstance.getDescribe().getName();
}
}
return null;
}

private Schema.SObjectType getObjectTypeFromId(String idObject)
{
return ((ID)idObject).getSObjectType();
}

public void save(){

update gObject;
}
}

 

------------------- And My component is

<apex:component controller="GenericObject">
<apex:form >
<apex:pageblock title="Generic Object" >
<apex:pageBlockSection title="Generic Object">
<apex:repeat value="{!describeList}" var="op">
<apex:outputField value="{!gObject[op]}" />
</apex:repeat>
<apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<!-- <apex:commandButton value="Edit" action="{!save}" id="editButton" /> -->
<apex:commandButton value="Save" action="{!save}" id="saveButton" />
<apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/>
</apex:pageBlockButtons>
</apex:pageblock>
</apex:form>
</apex:component>

--------------------- I try to Save Button Works !!! and i cannot do that.

I have the next error

 

Visualforce Error
 


System.LimitException: DML currently not allowed 

 

Class.GenericObject.save: line 120, column 1