Closed ghost closed 6 years ago
@pbrondum what is the error? Is it a compile-time error? Your then
is not returning a Promise
so I believe your code will not compile as-is.
Isn't org() and organization() supposed to return information from the organization object just like identity does for the user object? Or am I missing something?
Anyway, I'm trying to get nameSpacePrefix from organization() and it does not return that info. It returns identity information.
Thanks,
Per
Regards,
Per Jakobsen
Regular mail : perbrondum@gmail.com Secure Mail: isper@protonmail.com
On Tue, Dec 26, 2017 at 2:25 PM, Michael Epstein notifications@github.com wrote:
@pbrondum https://github.com/pbrondum what is the error? Is it a compile-time error? Your then is not returning a Promise so I believe the code will not compile as-is.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mike4aday/SwiftlySalesforce/issues/55#issuecomment-354019792, or mute the thread https://github.com/notifications/unsubscribe-auth/AA4tYg-NZX3SbBlQY2Q3Wh0qssgJ3re0ks5tEXJzgaJpZM4RMJWN .
@pbrondum would you post your code, and the results?
Your understanding is largely correct. org()
returns the promise of an Organization
struct; identity()
returns the promise of an Identity
struct.
Since it looks like organization() uses identity(), and validates the userid,
open func organization() -> Promise
return identity().then {
(identity: Identity) -> Promise
self.retrieve(type: "Organization", id: identity.orgID)
}
}
I assumed I should be able to do the following:
first {
// Get namespaceprefix of current user
salesforce.organization()
}.then {
orgInfo -> Promise<QueryResult<AccountData>> in
guard orgInfo.nameSpacePrefix != "" else {
throw WiWoError.generic(code: 100, message: "Can't
determine nameSpacePrefix for user") }
I get the error: "Value of type 'Organization' has no member 'nameSpacePrefix'"
Regards,
Per Jakobsen
Regular mail : perbrondum@gmail.com Secure Mail: isper@protonmail.com
On Tue, Dec 26, 2017 at 10:37 PM, Michael Epstein notifications@github.com wrote:
@pbrondum https://github.com/pbrondum would you post your code, and the results?
Your understanding is largely correct. org( ) returns the promise of an Organization struct; identity( ) returns the promise of an Identity struct.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mike4aday/SwiftlySalesforce/issues/55#issuecomment-354061597, or mute the thread https://github.com/notifications/unsubscribe-auth/AA4tYm-ytuqfiwF4OabJ4nlbca0ozlbBks5tEeWcgaJpZM4RMJWN .
@pbrondum is that a compile-time error? The correct property name is Organization.namespacePrefix
-- first "p" is lower-case. See Organization.swift
salesforce.organization()
calls identity()
first in order to get the current user's org ID, and then it retrieves the Organization
object for that ID.
In my code above. if you type orginfo. you get a list of Identity properties, not organization properties. I don't think organization return the expected properties.
guard orgInfo.nameSpacePrefix != "" else {
throw WiWoError.generic(code: 100, message: "Can't
determine nameSpacePrefix for user") }
Regards,
Per Jakobsen
Regular mail : perbrondum@gmail.com Secure Mail: isper@protonmail.com
On Wed, Dec 27, 2017 at 9:29 AM, Michael Epstein notifications@github.com wrote:
@pbrondum https://github.com/pbrondum is that a compile-time error? The correct property name is Organization.namespacePrefix -- first "p" is lower-case. See Organization.swift https://github.com/mike4aday/SwiftlySalesforce/blob/master/SwiftlySalesforce/Classes/Organization.swift
salesforce.organization() calls identity() first in order to get the current user's org ID, and then it retrieves the Organization object for that ID.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mike4aday/SwiftlySalesforce/issues/55#issuecomment-354147157, or mute the thread https://github.com/notifications/unsubscribe-auth/AA4tYqszS5eSM2R9x6AKMNiF8B07cjGaks5tEn5jgaJpZM4RMJWN .
@pbrondum I will verify shortly. Does your code compile? The property is namespacePrefix
(first "p" is lowercase). Also note that it is an optional string, so you probably want to test for nil, rather than for empty string.
@pbrondum I'm not able to reproduce that; organization()
and org()
are both returning a Promise<Organization>
which is fulfilled correctly. I put a breakpoint on line 730 in the test file, and I do see the expected Organization
struct.
Ok - error must be on my side then. I'll try again tomorrow. Thanks for looking into this.
Per
Regards,
Per Jakobsen
Regular mail : perbrondum@gmail.com Secure Mail: isper@protonmail.com
On Wed, Dec 27, 2017 at 9:14 PM, Michael Epstein notifications@github.com wrote:
@pbrondum https://github.com/pbrondum I'm not able to reproduce that; organization() and org() are both returning a Promise
which is fulfilled correctly. I put a breakpoint on line 730 in the test file https://github.com/mike4aday/SwiftlySalesforce/blob/aa4bebaf972deb6f7ff935925d81ad92c79d8e3f/Example/Tests/SalesforceTests.swift#L730, and I do see the expected Organization struct. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mike4aday/SwiftlySalesforce/issues/55#issuecomment-354230110, or mute the thread https://github.com/notifications/unsubscribe-auth/AA4tYvuFh3h3DhyKHN1yO6moUJMK4zS_ks5tEyPAgaJpZM4RMJWN .
Should the following not work? (a la identity()) first { in
if let nameSpacePrefix = org.nameSpacePrefix {
print("using namespaceprefix (nameSpacePrefix)")
}
}
salesforce.organization() }.then { (org) -> Promise