RForcecom icon indicating copy to clipboard operation
RForcecom copied to clipboard

getObjectDescription problems with some objects

Open akiraFuk opened this issue 7 years ago • 8 comments

I have problems to get some objects descriptions, like 'opportunity and Lead.

ERROR :

Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : arguments imply differing number of rows: 1, 0

when i search for a reason, i found problem in "xdfDFList <- sapply(xdfList, data.frame)"

i rewrite some codes to work with JSON, just because is easier for me.

akiraFuk avatar Oct 12 '17 19:10 akiraFuk

I am also having this issue where certain objects throw up this error and others do not. Does anyone have a fix or workaround for it?

Thanks

Thomas-Foster avatar Nov 13 '17 10:11 Thomas-Foster

I am having the same issue.

Anyone figured it out?

Thanks.

ermyuriel avatar Nov 24 '17 18:11 ermyuriel

I edited the function to use json. Its a little different result, but worth for me

Em 24 de nov de 2017 4:35 PM, "eucj" [email protected] escreveu:

I am having the same issue.

Anyone figured it out?

Thanks.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hiratake55/RForcecom/issues/65#issuecomment-346881006, or mute the thread https://github.com/notifications/unsubscribe-auth/AXjQBrVDrO5_UNY53Dx-2bJzHCRHhqQ3ks5s5wxPgaJpZM4P3hbZ .

akiraFuk avatar Nov 24 '17 18:11 akiraFuk

@akiraFuk can you share the modifications you did to fix the function?

Thanks

Thomas-Foster avatar Nov 27 '17 09:11 Thomas-Foster

_function(objectName) {

endpointPath <- objectName %>% private$zeusApiGetObjectDescriptionEndpoint()

URL <- private$session_sf['instanceURL'] %>% paste(endpointPath, sep='')

OAuthString <- 'Bearer' %>% paste(private$session_sf['sessionID'])

httpHeader <- httr::add_headers("Authorization"=OAuthString, "Accept"="application/json", 'Content-Type'="application/json")

res <- httr::GET(url=URL, config=httpHeader)

resContent <- res %>% httr::content(as='text', encoding = 'UTF-8')

jsonContent <- resContent %>% jsonlite::fromJSON()

df <- jsonContent$fields

colSelect <- c('name','label','custom','relationshipName','soapType')

df[,colSelect] %>% return()

}_

I Used this function inside my personal class.

I did few changes in original function. Just work with JSON insted of XML.

akiraFuk avatar Nov 27 '17 18:11 akiraFuk

Dropping a +1 here, i'm having the same issue. Not sure how to adapt code from @akiraFuk either. Anyone know how to resolve?

jcress avatar Feb 28 '18 18:02 jcress

If anyone is still having the issue - A fix from another thread worked well for me. Credit goes to @BenoitFayolle

Edit the function, replacing the existing definitions for xdfList and xdfDFList.

trace(rforcecom.getObjectDescription, edit = TRUE)

xdfList <- sapply(xdf,xmlToList)
xdfListClean <- sapply(xdfList,
                       function(x){
                         x_clean=x
                         isList=sapply(x,is.list)
                         if(sum(isList)>0)
                           x_clean[which(isList==T)]=sapply(x[which(isList==T)],
                                                            function(y){paste(y,collapse=",")})
                         x_clean
                       })
xdfDFList <- sapply(xdfListClean, data.frame)

bradlide avatar Aug 08 '19 22:08 bradlide

@bradlide thanks for the solution! Perfectly working for me. Many thanks to @BenoitFayolle too.

MykolaGolubenko avatar Oct 29 '19 21:10 MykolaGolubenko