Best practice for managing context saves with MagicalRecord? - core-data

I just downloaded the latest version (Developer) from MagicalRecord to fix a few warnings I got when validating my app's latest update.
I now find that MR_saveNestedContexts is deprecated, and is replaced by MR_saveToPersistentStoreWithCompletion:^(BOOL success, NSError *error).
This seems to be a lot of code to write to save each change/addition to the Core Data store; I have 17 different places in my app where I use MR_saveNestedContexts. My thoughts were to create a method and pass it the parameters, based on this article from Loriot.
While thinking about this, I was wondering if there was such a thing as "best practices" for MR?

I cannot give general advice how to handle Core Data save errors. Depending on the
data and the application, it might make sense to report a failure to the user, or
display a "failed" status in some UI element, or just NSLog it.
In the simplest case, you could replace MR_saveNestedContexts by
MR_saveToPersistentStoreWithCompletion:nil, and use the MagicalRecord error handling
methods (setErrorHandlerTarget:action:) to report or log the error.

Related

NetSuite 2015_2 PHP-SDK Two Factor Authentication

We currently have Two Factor Authentication working in the 2017_2 release of the NetSuite PHP Toolkit, but we have some code that has broken due to changes between 2015_2 and 2017_2. It seems that in 2017_2 it is also far easier to set up Two Factor Authentication.
Looking at the code, however I do see references to TokenPassport and TokenPassportSignature, which tells me that I should be able to get TBA working in 2015_2, which would give us time to figure out the rest of the issues.
My question is: How would I actually go about that? I have set $service->passport to the generated TokenPassport object. I know that my TokenPassport object works in 2017_2, and I assume it would be the same, but I don't know for sure, and I can't seem to find any information up on Elgoog.
ETA: I have seen examples of this working in 2015_2 in Ruby, but not in PHP. The backend is there, but I can't seem to be able to do this in PHP, and the Ruby examples were only snippets.
Okay, so I solved this for myself, but I may not have done it the "right" way. Here's what I did:
I took the makeSoapCall and setTokenGenerator methods from the new instance of NSPHPClient.php, and I added them to the OLD version. I had to modify the setTokenGenerator method to not require an instance of iTokenPassportGenerator, but I could have just as easily copied over that interface as well.
Basically, all that needs to happen is that we need to send the tokenPassport header, which the older version of the SDK can generate but doesn't have a method to actually send that I could find.

Office-js doesn't display the properties

I was trying to repro a tutorial about the creation of an Excel Add-in when something get wrong with the IntelliSense of Visual Studio. I was writing this code:
function updateStocks() {
Excel.run(function (ctx) {
var **range** = ctx.workbook.names.getItem("Stocks")
At this step, everything was fine, but after the getItem, I have tried to add .getRange() at which point the IntelliSense was not able to understand anything related to my variable range.
Screenshot
What is really "funny" is the fact that even if the properties are not displayed, when I write the code of the tutorial manually, the code is executed without mistake.
Why does this behavior occur and how can I correct it?
Are you able to see IntelliSense for other types within that .run? I.e., do you have everything up to the point where you get a Range from a named item? If you were to obtain the range differently (e.g., context.workbook.getSelectedRange()), do you get IntelliSense then?
This might be related to an issue (now fixed) where the CDN accidentally had the namedItem.getRange method removed (it was the only one that was affected, and we've put in measures to ensure we catch those in the future). See "Can't get range from a defined name". The CDN has been patched a couple weeks ago, but the JS IntelliSense file ("VSDOC") probably hadn't. If that's the case, it's a point-in-time issue that should resolve itself very very soon, as new deployments of the CDN will have the getRange method both in the VSDOC and everywhere else.
FWIW, you may still run into limitations of the JS IntelliSense engine (there are plenty, unfortunately: for example, trying to pass values across Promises, or passing in API objects as parameters to functions). The only true good workaround for this is using TypeScript, which allows you to declaratively assert to the compiler/IntelliSense-engine that "I know this type is an Excel.Range!") -- and offers a number of other goodies, async/await being a very major one. I personally believe that if you really want a "premier" Office.js-coding experience, TypeScript is the way to go. To that end, I describe how to use TypeScript in my book, "Building Office Add-ins using Office.js" (full disclosure, I am the author; but I've had many readers comment on how helpful of a resource it's been to them). The book is very much TypeScript-oriented, IntelliSense being one of the reasons (and async/await and let being the primary others) -- though I also offer an Appendix where I describe the JavaScript-only way of accomplishing the same Office.js tasks. It takes only a small amount of effort to get started with using TypeScript, and once you do, I don't think you'll look back.

UFT error: Cannot identify the object

I'm using Unified Functional Testing v12.02 (or QTP).
Sometimes while running script i get the below error and sometimes I don't.
Cannot identify the object "..." (of class ...) Verify that this
object's properties match an object currently displayed in your
application.
Tip: If the objects in your application have changed, the Maintenance
Run Mode can help you identify and update your steps and/or the
objects in your repository.
I checked OR and the object itself with Spy tool and they have the same properties.
Sometimes I get the same error in other objects, but if I run again the script it works well.
Can someone explain me what might be the problem?
Im a little bit confused why sometimes i get these errors and sometimes don't.
I'm testing a simple web application (for training purposes)
Also I'm using the following add-ins: Web, Web-SAPUI5, Visual Basic
Mostly object wont be in the readystate. Check State of the Object using
Webedit(googlesearch).object.readyState="complete"
Webedit(googlesearch).object.Load
Webedit(googlesearch).object.Disabled=False

How do you rollback updates with jdbcRowSet?

I can use acceptChanges, jdbcRowSet1.acceptChanges(); , with my jdbcRowSet data source to accept the changes (updates, deletes, etc). How would I rollback or cancel any updates, deletions, etc.???
I tried jdbcRowSet1.rollback(); but got an error.
Error while executing JavaScript action expression
Script interpreter error, line=1, col=13: Unknown member 'rollback' in Java class 'com.ibm.xsp.extlib.jdbc.model.JdbcRowSetAccessor'
JavaScript code
1: jdbcRowSet1.rollback();
Anyone try this yet?
thanks, Howard
The jdbcRowSet data source does not currently support rollback(). We could add support for this in the future perhaps (no guarantees). From my reading, there is a method RowSet.cancelRowUpdates() that we could use in our jdbcRowSet implementation for this, but it only cancels updates to a row, and doesn't cancel deletions/insertions.
A simple potential solution for your issue would be to reload the page via javascript call, context.reloadPage(), and that will discard the current rowSet. Simplistic solution, but it may do the trick for you.
Your questions is really less XPages specific, and more about general SQL management in Java, so if you want a more indepth answer than I provide, you may want to update your tags.
More than likely your connection has autocommit set to true. This forces the data set to commit changes as you make them immediately, so there is nothing to roll back. The rollback() method is from the connection object related to the row set, and will not provide a rollback when autocommit is true, hence the error you get.
You need to look into changing your auto commit to false, then make sure you call commit() or rollback() when you are done with your changes. If you have multiple transactions occurring, you should look into the the connection manager as well. I touch in this briefly in the chapter on the SQL controls in the Extension Library book from IBM Press.

What is the correct way of using the xcdatamodels parameters in the apportable config file? I believe this is for using Core Data

Maybe I didn't set the correct APPORTABLE config parameters when using CoreData. I can ADD,EDIT,DELETE and List down the current records when the app is running. But when I remove it from the current running apps and tried to Open my app again all of the data are gone. Maybe setting the correct parameter would eliminate this bug I am encountering right now?
You shouldn't have to set the xcdatamodel list in the configuration.json unless you have a special apportable-specific xcdatamodel. the model should now automatically be compiled and put into the app bundle. in fact, if you were using our coredata before this change, i recommend undoing everything you have done in order to get it to work. it should just work.
as for your issue, would you mind creating a test case and then emailing it to sdk # apportable.com? it's tough to debug without a reduced test case that demonstrates the bug.
update: we didn't have hasChanges properly implemented in NSManagedObjectContext. We've implemented it better, and now the test project works. Look for it the next version of the SDK (could be a few days to a week for that), and let me know if you still have trouble.

Resources